Browse button for file upload 404 file directory n

2019-09-03 08:56发布

Hi I am currently trying to create an upload section for my website, i have looked at multiple websites and examples such as:

W3Schools

I have found out that there are multiple ways that these can go wrong for example mysql injection is each due to them using the $_FILES["file"]["type"]. So I have started to follow this link instead due to it being from php them selves, PHP Documentation

Ok to get to the point I have a problem with the code that I have at the moment I have a simple form that runs the PHP script to check the file upload and then upload if it is correct and come up invalid if it isn't this is partially working, the file uploads but if it is a large file I get a 404 file or directory not found error but if it is a smaller file size it works any ideas.

The HTML form is

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

and the PHP file code is

    <?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.

$uploaddir = './';//
$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";
}

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

print "</pre>";

?>

any ideas would be much appreciated or if anybody knows a better example to use.

3条回答
Bombasti
2楼-- · 2019-09-03 09:16

I'm not very familiar with Windows Server, but I googled a bit and found this document:

http://www.webmasterworld.com/microsoft_asp_net/3986574.htm

This says your php.ini file should be located under:

C:\Windows\System32\PHP\php.ini

if you found this file, find and edit the following lines:

; Maximum allowed size for uploaded files.
upload_max_filesize = 40M

; Must be greater than or equal to upload_max_filesize
post_max_size = 40M

hope this helps! :-)

查看更多
beautiful°
3楼-- · 2019-09-03 09:31

check your upload_max_filesize - 2M in your php.ini file

查看更多
SAY GOODBYE
4楼-- · 2019-09-03 09:35

The maximum file size may be limited in PHP. In php.ini, check the following properties:

upload_max_filesize = 10M
post_max_size = 10M

If it makes no change, you can also try checking memory limit or maximum process time.

查看更多
登录 后发表回答