douxiaqin2062 2014-01-02 12:41
浏览 75
已采纳

PHP move_uploaded_file不起作用

I'm using HTTP post to upload image to server and I have the following PHP code:

$base_path = "";
$target_path = $base_path . basename ( $_FILES ['uploadfile'] ['name'] );
if (move_uploaded_file ( $_FILES ['uploadfile'] ['tmp_name'], $target_path )) {
    echo "Good";
} else {
    echo "FAIL";
}

I'm sure the image has been uploaded to temp. But no matter what, I just can't store image file. my current permission is 664 for testing.

  • 写回答

2条回答 默认 最新

  • douping1825 2014-01-02 12:51
    关注

    You need to set your $base_path variable to an absolute path to where you are storing the file. ( ie. /path/to/your/document/root/image/directory/ )

    Additionally, make sure the directory you will be storing the images in is either owned by the apache user or that it is writable by the apache user (chmod 777).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 同步两个不同结果的array中某些属性
  • ¥15 悬赏15远程操控解决问题
  • ¥15 CST复制的模型无法单独修改参数?
  • ¥15 前端页面想做个定时任务,但是使用requestAnimationFrame,setinterval和settimeout都不行
  • ¥15 根据以下文字信息,做EA模型图
  • ¥15 删除虚拟显示器驱动 删除所有 Xorg 配置文件 删除显示器缓存文件 重启系统 可是依旧无法退出虚拟显示器
  • ¥15 vscode程序一直报同样的错,如何解决?
  • ¥15 关于使用unity中遇到的问题
  • ¥15 开放世界如何写线性关卡的用例(类似原神)
  • ¥15 关于并联谐振电磁感应加热