使用MAMP上传4kb文件

时间:2011-02-02 14:33:55

标签: php file-upload mamp

我正在尝试使用MAMP上传文件(OS X上为1.9.4)。 我使用这个脚本I found here

以下是表单代码:

<form enctype="multipart/form-data" action="uploader.php" method="POST">
<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>

uploader.php代码:

$target_path = "uploads/";

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

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!";
}

uploads文件夹确实存在,但是当我提交表单时,出现以下错误:

There was an error uploading the file, please try again!

我该如何解决这个问题? 谢谢,

问候。

编辑:在phpinfo(5.3.2)中,文件上传“打开”。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案!

而是使用$_FILES,我尝试并使用了$HTTP_POST_FILES。 而是move_uploaded_file,我使用了副本function

有人可以给我一个解释吗?

感谢。