文件未上传给出错误“文件未上传请再试一次”?

时间:2014-04-18 08:25:05

标签: php jquery mysql css file-upload

我是初学者,我试图将文件从此tutorial上传到uploads/文件夹,但是在我提交程序后显示错误{ {1}}你能告诉我这里有什么问题吗?

form.php的:

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

uploader.php

<html>
<head>
    <title>Form image</title>
</head>
<body>
<form enctype="multipart/form-data" action="uploader.php" method="post" name="changer">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000">
    <input type="file" name="uploadedfile" accept="image/jpeg">
    <input type="submit" value="Submit">
</form>
</body>
</html>

1 个答案:

答案 0 :(得分:2)

正确的代码是

move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)

您正在使用

move_uploaded_file($_FILES['uploadedfile']['name'], $target_path)

这不起作用,因为在启动上载后文件存储在temp文件夹中,并且在移动文件时它必须知道临时名称,以便可以将文件从临时文件夹移动到服务器。