I've been working on a script for uploading a file to a Unix server. I'm 
testing the script and have it coded for error messages using a switch 
statement.  One error that I am getting is case 2 "The file is bigger than this 
form allows" and I am wondering what might cause me to get the error for case 1 
"The file is bigger than this PHP installation allows".

Thank you,
Althea


<form enctype="multipart/form-data" action="getfile.php" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="50000" />
    
    <!-- Name of input element determines name in $_FILES array -->
    Send this file: <input name="userfile" type="file" />
    <br /><br />
    <input type="submit" value="Send File" />
</form>

---------------------------------------------
$uploaddir = '/home/httpd/vhosts/foxedge.net/httpdocs/lvs/phpclass/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo "File is valid, and was successfully uploaded.\n";
} else {
   echo "Possible file upload attack!\n";
    switch ($_FILES['userfile'] ['error'])
         {  case 1:
                   print '<p> The file is bigger than this PHP installation 
allows</p>';
                   break;
            case 2:
                   print '<p> The file is bigger than this form allows</p>';
                   break;
            case 3:
                   print '<p> Only part of the file was uploaded</p>';
                   break;
            case 4:
                   print '<p> No file was uploaded</p>';
                   break;
   
         }
}

echo 'Here is some more debugging info:';
print_r($_FILES);

echo "</pre>";


Reply via email to