doujiu3095 2017-01-31 09:35
浏览 46
已采纳

PHP fileupload错误6

my PHP upload fails with an error:6 but I don't know why. I checked all the parameters which are descriped in some stackoverflow posts, but without a soulution.

Header of the Request

As you see, I just get an error 6. All the values (TMP_DIR, SYS_TMP_DIR) are set, but it does not work.

Overview FirePHP logs

The apache user has the permission to access /tmp on the server.

Is there an issue I have overlooked?

require_once '../libs/firephp-core-0.4.0/lib/FirePHPCore/fb.php';
$tmp = getcwd()."/tmp";

ini_set('open_basedir', $tmp);
ini_set('upload_tmp_dir',$tmp);

ob_start();
fb($_FILES, "FILES");
fb(ini_get('open_basedir'), 'OPEN_BASEDIR');
$tmp_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();
fb($tmp_dir, "TMP_DIR");
fb(sys_get_temp_dir(), "SYS-TMP-DIR");

$uploaddir =  getcwd()."/uploads/";
$uploadfile = $uploaddir . basename.basename($_FILES['x0']['name']);
fb($uploadfile, 'FILE PATH');
fb(move_uploaded_file($_FILES['x0']['tmp_name'], $uploadfile), "MOVE RESULT");
  • 写回答

2条回答 默认 最新

  • duanquezhan7268 2017-01-31 09:47
    关注

    The upload_tmp_dir configuration must be set in the php.ini file so that it is available before the script is running. When the script starts to run the file is already uploaded (or not in case of an error).

    ini_set('upload_tmp_dir',$tmp);

    I see that you try to set upload_tmp_dir but that statement is executed to late. Go to php.ini and set it there:

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

报告相同问题?

悬赏问题

  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含