Re: [PHP] Re: FIle Upload problems
Do yourself a favour, study the example in the manual, get it working, understand how it works, Lighten up Francis, it was 10pm at night after a 14 hour day and 62 hour week. I appreciate the help but can do without the cynicism. -- Brian V Bonini [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: FIle Upload problems
try echo'ing $_FILES['image_upload']['tmp_name'], and check if the path exists maybe some wrong configuration on php.ini upload_tmp_dir ? it is usually a good idea trying to isolate the smallest piece of code that gives the unwanted result makes it easier for other ppl to help, and sometimes you find out the bug, by yourself, on the way Brian V Bonini wrote: The form: form enctype=multipart/form-data action=?php echo $_SERVER['PHP_SELF'] ? method=POST input type=hidden name=MAX_FILE_SIZE value=1 fieldset legendAdd Rider/legend label for=rider_nameName:/label input type=text name=rider_name id=rider_name size=30 maxlength=30 /br / label for=rider_license_catLic. Cat.:/label input type=text name=rider_license_cat id=rider_license_cat size=2 maxlength=1 /br / label for=commentsComments:/label input type=text name=comments id=comments size=30 maxlength=30 /br / label for=image_uploadUpload Image:/label input name=image_upload id=image_upload type=file /br / pinput type=submit name=action value=Add Rider/p /fieldset /form The code: if (is_uploaded_file($_FILES['image_upload']['tmp_name'])) { move_uploaded_file($_FILES['image_upload']['tmp_name'], $upload_file_path); echo success; } else { echo Possible file upload attack. Filename: . $_FILES['image_upload']['name'] . br /\n; switch($_FILES['HTTP_POST_FILES']['userfile']['error']){ case 0: //no error; possible file attack! echo There was a problem with your upload.br /\n; break; case 1: //uploaded file exceeds the upload_max_filesize directive in php.ini echo The file you are trying to upload is too big.br /\n; break; case 2: //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form echo The file you are trying to upload is too big.br /\n; break; case 3: //uploaded file was only partially uploaded echo The file you are trying upload was only partially uploaded.br /\n; break; case 4: //no file was uploaded echo You must select an image for upload.br /\n; break; default: //a default error, just in case! :) echo There was a problem with your upload.br /\n; break; } } } No matter what I try this keeps falling through to the default switch. -- André Cerqueira signature.asc Description: OpenPGP digital signature
Re: [PHP] Re: FIle Upload problems
On Fri, 2004-03-05 at 21:33, Andre Cerqueira wrote: try echo'ing $_FILES['image_upload']['tmp_name'], and check if the path exists Gives me nothing, hmmm... maybe some wrong configuration on php.ini upload_tmp_dir ? %more php.ini ls -l / | grep tmp register_globals = On upload_tmp_dir = /tmp file_uploads = 1 drwxrwxrwt 29 root wheel1536 Mar 5 21:39 tmp In the form if I trim off the local /PATH/to/file/ it returns successful and created a 0 byte file where it should. Obviously not what ultimately needs to happen but Am I supposed have to translate the local path first of something? -- Brian V Bonini [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: FIle Upload problems
On Saturday 06 March 2004 10:42, Brian V Bonini wrote: On Fri, 2004-03-05 at 21:33, Andre Cerqueira wrote: try echo'ing $_FILES['image_upload']['tmp_name'], and check if the path exists Gives me nothing, hmmm... If you had enable error reporting and checked what errors were reported you would probably have solved your problem already. In the form if I trim off the local /PATH/to/file/ it returns successful and created a 0 byte file where it should. Obviously not what ultimately needs to happen but Am I supposed have to translate the local path first of something? I don't see anywhere in your form where you have /PATH/to/file/, what are you referring to? Also the following is obviously incorrect ... switch($_FILES['HTTP_POST_FILES']['userfile']['error']){ ... it should be ... switch($_FILES['userfile']['error']){ ... and you should have substituted 'userfile' with 'image_upload' as that is what you're using in your form. Do yourself a favour, study the example in the manual, get it working, understand how it works, THEN modify it in small incremental steps until it does what you want. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Live from New York ... It's Saturday Night! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php