PHP move_uploaded_file()失败,我不知道为什么 [英] PHP move_uploaded_file() FAILS and i don't know why

查看:236
本文介绍了PHP move_uploaded_file()失败,我不知道为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

  $ uploaddir ='/ temp /'; 
$ uploadfile = $ uploaddir.basename($ _ FILES ['file'] ['name']);
$ b $ if(move_uploaded_file($ _ FILES ['file'] ['tmp_name'],$ uploadfile))
send_OK();
else
send_error(ERROR - uploading file);

我已经尝试使用ftp_fput,ftp_put,move_uploaded_file,rename,copy以及任何可以将我手上。

我不明白是什么问题,因为move_uploaded_file只返回true或false,没有错误代码。

help

解决方案

您确定目标目录对 world ?即权限表示中的第三个数字?
由php上传的文件归属于 www-data



改变所有权
$ b $ pre $ su $ chown -R www-data文件夹//改变所有者
sudo chown -R www-data:www-data文件夹//改变组和所有者


this is my code:

$uploaddir = '/temp/';
$uploadfile = $uploaddir.basename($_FILES['file']['name']);

if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile))
    send_OK();
else
    send_error("ERROR - uploading file");

i have tried to upload with ftp_fput, ftp_put, move_uploaded_file, rename, copy and anything i can put my hands on. nothing seems to work.

i can't understand what is the problem since move_uploaded_file returns only true or false and no error code.

help??

解决方案

Are you sure that the target directory has write permissions for world?ie,the third number in permission representation? The files uploaded by php are owned by and comes under the group www-data

You can change the ownership by

[sudo] chown -R www-data folder // change owner
[sudo] chown -R www-data:www-data folder // change group and owner

这篇关于PHP move_uploaded_file()失败,我不知道为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆