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条)

报告相同问题?

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装
  • ¥40 复杂的限制性的商函数处理