[ciapug] File Upload
Carl Olsen
carl-olsen at mchsi.com
Tue Feb 21 13:53:52 CST 2006
I'll give it a try.
Thank you!
Carl
-----Original Message-----
From: ciapug-bounces at cialug.org [mailto:ciapug-bounces at cialug.org] On Behalf
Of Tony Bibbs
Sent: Tuesday, February 21, 2006 9:17 AM
To: barry at vonahsen.com; ciapug at cialug.org
Cc: carl-olsen at mchsi.com
Subject: Re: [ciapug] File Upload
Alternatively, here's a class I wrote for doing similar file uploads:
http://cvs.geeklog.net/co.php?r=1.43&f=geeklog-1.3%2Fsystem%2Fclasses%2Fuplo
ad.class.php
--Tony
Barry Von Ahsen wrote:
> for file uploads, I found this once on php.net (I don't see it now)
>
> if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
> switch($_FILES['file']['error']){
> case 0: //no error; possible file attack!
> $errtxt .= "There was a problem with your upload.";
> break;
> case 1: //uploaded file exceeds the upload_max_filesize directive in
> php.ini
> $errtxt .= "The file you are trying to upload is too big.";
> break;
> case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was
> specified in the html form
> $errtxt .= "The file you are trying to upload is too big.";
> break;
> case 3: //uploaded file was only partially uploaded
> $errtxt .= "The file you are trying upload was only partially
> uploaded.";
> break;
> case 4: //no file was uploaded
> $errtxt .= "You must select a file for upload.";
> break;
> default: //a default error, just in case! :)
> $errtxt .= "There was a problem with your upload.";
> break;
> }
> }
>
> -barry
>
>
> Carl Olsen wrote:
>> I ran into an unusual situation today creating a file upload script.
>> I have
>> the php.ini settings for memory_limit, upload_max_filesize, and
>> post_max_size all set to 10M. I have a form with a hidden field
>> MAX_FILE_SIZE just before the file input box set to 10000000 (10 million
>> bytes, slightly less than 10M). I have a function that checks both
>> the file
>> extension and the file type, so it only allows files of certain types
>> to be
>> uploaded. I get unusual results. When I upload most files that do
>> not fit
>> the required type, it give me one of my custom error messages. When I
>> upload a file that is too big, it doesn't do anything (MAX_FILE_SIZE
>> prevents the form from posting). However, when I upload a file with
>> an .exe
>> file extension that is 54MB, I get a machine error that starts out "PHP
>> Warning" at the bottom of the page.
>>
>> What I would really like to do is figure out how to write some PHP
>> code to
>> intercept the machine error and display a custom error on the page,
>> but it
>> appears to be outside the scope of any PHP code I can insert into the
>> page.
>> Has anyone seen this before?
>>
>> Carl Olsen
>>
>> _______________________________________________
>> ciapug mailing list
>> ciapug at cialug.org
>> http://cialug.org/mailman/listinfo/ciapug
>
>
> _______________________________________________
> ciapug mailing list
> ciapug at cialug.org
> http://cialug.org/mailman/listinfo/ciapug
_______________________________________________
ciapug mailing list
ciapug at cialug.org
http://cialug.org/mailman/listinfo/ciapug
More information about the ciapug
mailing list