开发者

php uploader $_FILES undefined

Hello everyone I been trying get php uploader working but having a lot of issues. Here is my code. I'm getting Undefined Index errors on the $_FILES. Am I missing something? I checked the php.ini for the max file size and a list of other things. I checked my tmp folder nothing in it. I was able to use this a little while ago but when I increased my max file upload it seemed like everything broke..

PHP FILE

ini_set('display_errors', 1);
ini_set('log_errors', 1);
error_reporting(E_ALL);

// Where the file is going to be placed 
$target_path = 'Test/';

$target_path = $target_path. basename( $_FILES['uploadedfile']['name']); 

printf($_FILES);
print_r($_FILES);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) 
{
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} 
else
{
    echo "There was an error uploading the file, please try again!";
}

?>

HTML FILE

    <form method="post" action="UploadPHP.php" enctype="multipart/form-data">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" />
    </form>


</body>
</html> 

The Error I'm getting

Notice: Undefined index: uploadedfile in /Movies/UploadPHP.php on line 10 
Notice: Array to string conversion in /Movies/UploadPHP.php on line 12 ArrayArray ( ) 
Notice: Undefined index: uploadedfile in /Movies/UploadPHP.php on line 15 
There was an error uploading the file, please try again!

So I dec开发者_开发百科ided to look at some other stuff and now the server wont accept any posts! I have no idea what went wrong I changed the post size to : 2048M and restarted apache.... So lost now.


You may be getting those errors when the form attempts to submit the file to the script, but there was no file sent to the script. Make sure you do checking prior for the $_FILES['uploadedfile'] to be set prior to trying to move an uploaded file out of the temp directory.

Your MAX_FILE_SIZE is only set to 100000 bytes, so it's only 97.65625KB, make sure the file you are uploading is less than that size. Otherwise as I recall, it does not submit the form.


Check "upload_max_filesize" in .htaccess. if the provided file size is greater then specified, then $_FILES will not get anyting.

Thanks


I was working in a custom framework today where someone had "cleverly" moved $_FILES into another class variable and then called unset($_FILES).

Spent awhile tracking that one down, so check for hairballs like that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜