使用 MAMP 上传 4kb 文件
我正在尝试使用 MAMP(OS X 上为 1.9.4)上传文件。 我使用这个脚本我在这里找到:
这是表单代码:
<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) 中,文件上传处于“打开”状态。
I'm trying to upload a file with MAMP (1.9.4 on OS X).
I use this script I found here :
Here is the form code:
<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>
And the uploader.php
code:
$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!";
}
The uploads
folder does exist but when I submit my form, I get the following error:
There was an error uploading the file, please try again!
How can I resolve this?
Thanks,
Regards.
EDIT: In phpinfo (5.3.2), File upload is 'on'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决办法!
我尝试并使用了
$HTTP_POST_FILES
,而不是使用$_FILES
。我使用了复制
函数
,而不是move_uploaded_file
。谁能给我解释一下吗?
谢谢。
I found a solution!
instead using
$_FILES
, I tried and used$HTTP_POST_FILES
.And instead
move_uploaded_file
, I used the copyfunction
.Can anyone give me an explanation?
Thanks.