doraemon0769 2014-04-27 04:36
浏览 52
已采纳

为什么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.

  • 写回答

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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度