我收到以下错误
( ! ) Notice: Undefined index: file in C:\wamp\www\upload_file.php on line 18 Call Stack
# Time Memory Function Location 1 0.0003 377944 {main}( ) ..\upload_file.php:0
( ! ) Notice: Undefined index: file in C:\wamp\www\upload_file.php on line 24 Call Stack
# Time Memory Function Location 1 0.0003 377944 {main}( ) ..\upload_file.php:0 Upload:
( ! ) Notice: Undefined index: file in C:\wamp\www\upload_file.php on line 25 Call Stack
# Time Memory Function Location 1 0.0003 377944 {main}( ) ..\upload_file.php:0 Type:
( ! ) Notice: Undefined index: file in C:\wamp\www\upload_file.php on line 26 Call Stack
# Time Memory Function Location 1 0.0003 377944 {main}( ) ..\upload_file.php:0 Size: 0 Kb
( ! ) Notice: Undefined index: file in C:\wamp\www\upload_file.php on line 27 Call Stack
# Time Memory Function Location 1 0.0003 377944 {main}( ) ..\upload_file.php:0 Temp file:
( ! ) Notice: Undefined index: file in C:\wamp\www\upload_file.php on line 29 Call Stack
# Time Memory Function Location 1 0.0003 377944 {main}( ) ..\upload_file.php:0
( ! ) Notice: Undefined index: file in C:\wamp\www\upload_file.php on line 31 Call Stack
# Time Memory Function Location 1 0.0003 377944 {main}( ) ..\upload_file.php:0 already exists.
现在处理文件上传量的文件 是以下
?php session_start();
ini_set('memory_limit', "400M");
ini_set('max_execution_time', "900");
ini_set('upload_max_filesize', "400M");
ini_set('post_max_size', "400M");
$user=$_SESSION['MM_Username'];
$path="video". "\\" . $user . "\\";
if(!(is_dir($path))){
mkdir(dirname(__FILE__) . "\\". $path,0777);
}
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists($path . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
$path. $_FILES["file"]["name"]);
echo "Stored !";
}
}
?>
如果我尝试上传一张图片一切都很好,但是当我尝试上传一个300MB的动画片段它会给出我上面发布的错误,我已经更改了我的wamp服务器上的php.ini文件,它允许更大的文件到上传但仍无结果 有人知道什么是错的吗?
答案 0 :(得分:0)
您缺少表单上的enctype属性。
答案 1 :(得分:0)
您的代码中的另一个问题是您甚至不检查$ _FILES []数组中是否存在'file'索引。 如果没有,则应将此报告为错误,而不是尝试使用其内容。 这是更好的整体方法:在尝试使用表单之前,检查您希望表单中的每个字段是否存在。