Re: FIle Upload problems

From: Date: Sat, 06 Mar 2004 02:33:03 +0000
Subject: Re: FIle Upload problems
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-179622@lists.php.net to get a copy of this message
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="10000"> <fieldset> <legend>Add Rider</legend> <label for="rider_name">Name:</label> <input type="text" name="rider_name" id="rider_name" size="30" maxlength="30" /><br /> <label for="rider_license_cat">Lic. Cat.:</label> <input type="text" name="rider_license_cat" id="rider_license_cat" size="2" maxlength="1" /><br /> <label for="comments">Comments:</label> <input type="text" name="comments" id="comments" size="30" maxlength="30" /><br /> <label for="image_upload">Upload Image:</label> <input name="image_upload" id="image_upload" type="file" /><br /> <p><input 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

Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
« previous php.general (#179622) next »