文件未上传php

时间:2015-05-13 18:58:02

标签: php

更新

我现在已经解决了,问题是我没有预先设定的' /'我没有' /'最后,这是文件夹路径的最终语法:$folder = '/home/dl/www/uploads/';

更新

我已更新代码,以便输出更详细的调试信息,这就是输出:

Warning:  move_uploaded_file(home/dl/www/uploads/test.txt): failed to open stream: No such file or directory in /home/dl/public_html/file-upload/upload.php on line 9

我有以下脚本,它试图将选定的文件上传到我的Web服务器上的指定目录。但是,它没有上传;我已经检查过该目录的权限是在' 777'根据众多教程的建议,但仍然没有上传'文件未上传'消息。

有没有人建议为什么这可能不起作用?

谢谢!

<?php
$folder = "/home/dl/www/uploads";
if (is_uploaded_file($HTTP_POST_FILES['filename']['tmp_name']))  {   
    if (move_uploaded_file($HTTP_POST_FILES['filename']['tmp_name'], $folder.$HTTP_POST_FILES['filename']['name'])) {
         Echo "File uploaded";
    } else {
         Echo "File not moved to destination folder. Check permissions";
    };
} else {
     Echo "File is not uploaded.";
}; 
?>

HTML表单:

<html>
<head>
<title>File Uploading Form</title>
</head>
<body>
<h3>File Upload:</h3>
Select a file to upload: <br />
<form action="upload.php" method="post"
                        enctype="multipart/form-data">
<input type="file" name="file" size="50" />
<br />
<input type="submit" value="Upload File" />
</form>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

尝试

$folder = "/home/dl/www/uploads/";

而不是

$folder = "/home/dl/www/uploads";

也就是说,最后是斜线。