浏览按钮找不到文件上传404文件目录 [英] Browse button for file upload 404 file directory not found

查看:165
本文介绍了浏览按钮找不到文件上传404文件目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我目前正在尝试为我的网站创建一个上传部分,我已经看过多个网站和例如:

W3Schools


我发现那里是多种方式,这些可能会出错,例如mysql注入每个由于他们使用 $ _ FILES [文件] [类型] 。所以我已经开始遵循这个链接,而不是由于他们自己的PHP自己, PHP文档



好的,我现在有一个问题,我有一个简单的表单运行PHP脚本来检查文件上传,然后上传,如果正确,并出现无效,如果不是这是部分工作,文件上传,但如果它是一个大文件,我得到一个404文件或目录没有找到错误,但如果它是一个较小的文件大小,它可以工作任何想法。
$ b HTML表单是

 < form enctype =multipart / form-dataaction =upload_file.phpmethod =POST> 
<! - MAX_FILE_SIZE必须在文件输入字段之前 - >
< input type =hiddenname =MAX_FILE_SIZEvalue =300000000/>
<! - 输入元素名称决定$ _FILES数组中的名称 - >
发送此文件:< input name =userfiletype =file/>
< input type =submitvalue =发送文件/>





和PHP文件代码是

 <?php 
//在4.1.0之前的PHP版本中,应该使用$ HTTP_POST_FILES来代替
// $ _FILES。

$ uploaddir ='./';//
$ uploadfile = $ uploaddir。基名($ _ FILES [ userfile的] [名称]);

echo'< pre>';
if(move_uploaded_file($ _ FILES ['userfile'] ['tmp_name'],$ uploadfile)){
echo文件有效,已成功上传。
} else {
echo可能的文件上传攻击!\\\
;
}

echo'这是一些更多的调试信息:';
print_r($ _ FILES);

打印< / pre>;

?>

任何想法都会被赞赏,或者有人知道更好的例子。 b $ b

解决方案

PHP的最大文件大小可能有限。在 php.ini 中,检查以下属性:

  upload_max_filesize = 10M 
post_max_size = 10M

如果没有改变,您也可以尝试检查内存限制或最大的处理时间。


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.

解决方案

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.

这篇关于浏览按钮找不到文件上传404文件目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆