doucong3048 2016-02-12 07:35
浏览 149
已采纳

move_uploaded_file无效(php,nginx)

I am trying to use php function move_uploaded_file on production server and there is some strange error. Some files can be and some files can't be uploaded. Everything works on localhost.

// test for errors
if (!empty($file['errors'])) {
    log('ERR uploadImages: errors occured');
} else {
    log('OK uploadImages: errors empty');
}

// test is dir
if (!is_dir($path)) {
    log("ERR uploadImages: is_dir {$path}");
} else {
    log('OK uploadImages: is_dir');
}

// test on writable
if (!is_writable($path)) {
    log('ERR uploadImages: is_writable');
} else {
    log('OK uploadImages: is_writable');
}

// upload this file
$uploaded = move_uploaded_file($file['tmp_name'], $filepath);

// is uploaded?
if ($uploaded) {
    log('OK uploadImages: uploaded');
} else {
    log('ERR uploadImages: not uploaded');
}

And my log is:

OK uploadImages: errors empty
OK uploadImages: is_dir  
OK uploadImages: is_writable
ERR uploadImages: not uploaded

Some of files are uploaded, some not. In example:

jpeg 1.65MB - ERR
jpeg 1.48MB - ERR
jpeg 1.2MB - ERR
jpeg 0.9MB - OK
jpg 0.5MB - OK
mp3 6MB - ERR

So I have checked php.ini

post_max_size   100M
upload_max_filesize 600M
  • 写回答

1条回答 默认 最新

  • doutan1905 2016-04-15 06:10
    关注

    NGINX has his own config set to 1MB - client_max_body_size 1M;

    Solved

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

报告相同问题?

悬赏问题

  • ¥15 Attention is all you need 的代码运行
  • ¥15 一个服务器已经有一个系统了如果用usb再装一个系统,原来的系统会被覆盖掉吗
  • ¥15 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测