2014-04-27 04:36
浏览 38

为什么PHP move_uploaded_file()无法打开流?

I'm down to the most basic move and still struggling with it:

$path = '/home/*NAME*/public_html/ih/upload/';
$fileName = $_FILES["file"]["tmp_name"];

echo $path, "<br />"; echo $fileName;

move_uploaded_file($fileName, $path);

Both path and filename print the expected contents before the move fails. The path is identical to what I get when I echo getcwd() in the directory I want to move the files to. I've chmodded the upload folder and all subdirectories to 777 to be safe.

My error messages are:

Warning: move_uploaded_file(/home/*NAME*/public_html/ih/upload/) 
[function.move-uploaded-file]: failed to open stream: Is a directory in /home/*NAME*/public_html/ih/upload.php on line 11

Warning: move_uploaded_file() [function.move-uploaded-file]: 
Unable to move '/tmp/phph4oYFN' to '/home/*NAME*/public_html/ih/upload/' in /home/*NAME*/public_html/ih/upload.php on line 11

Does anyone know what I could do to fix this? Is it a permissions error? Thank you if so.

图片转代码服务由CSDN问答提供 功能建议

我采取了最基本的行动并仍然在努力: < pre> $ path ='/ home / * NAME * / public_html / ih / upload /'; $ fileName = $ _FILES [“file”] [“tmp_name”]; echo $ path,“ &lt; br /&gt;“; echo $ fileName; move_uploaded_file($ fileName,$ path);

路径和文件名都会在移动失败前打印预期的内容。 该路径与我在想要将文件移动到的目录中回显getcwd()时获得的路径相同。 我已经将上传文件夹和所有子目录chmodded到777是安全的。


 警告:move_uploaded_file(  / home / * NAME * / public_html / ih / upload /)
 [function.move-uploaded-file]:无法打开流:是/home/*NAME*/public_html/ih/upload.php中的目录 第11行
无法在/ home /中将'/ tmp / phph4oYFN'移动到'/ home / * NAME * / public_html / ih / upload /'  *第11行的名称* / public_html / ih / upload.php 

有谁知道我可以做些什么来解决这个问题? 是权限错误吗? 谢谢你,如果是的话。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongti7838 2014-04-27 04:39

    The clue is here:

    [function.move-uploaded-file]: failed to open stream: Is a directory...

    You've passed a directory path as an argument to move_uploaded_file(). You need to pass a filename.

    Perhaps you want

    move_uploaded_file($fileName, $path.$fileName);

    This won't handle duplicate names well, though.

    打赏 评论

相关推荐 更多相似问题