dongping1922 2010-06-25 14:26
浏览 25
已采纳

使用php上传大文件后,“没有这样的文件”错误

There is a service for uploading large files (more than 500MB) with php/apache. The progress of upload is tracked by the uploadprogress pecl extension. This scheme works fine only for small file uploads.

However, there is a problem when uploading large files. Once the upload is finished, there is a standard information in the $_FILES array showing there are no errors. The problem is that the /tmp/phpXXXX file itself doesn't exist by this time.

I've tested that if we manually remove the tmp file during the upload, upload process will not stop and the error will be raised only after the upload is finished.

Hosting provider says that there are no maintenance scripts that are removing tmp files. Also it says that such tmp files are available in the filesystem almost until the end of the upload, and then they disappear.

Could it be caused by the apache/server/php configuration? Is there anything in the OS that may affect these tmp files?

OS is Ubuntu 8 LTS

Any help would be appreciated!

  • 写回答

4条回答 默认 最新

  • doushanmo7024 2012-03-24 18:11
    关注

    There is a number of reasons why uploaded files might not work.

    • upload_max_filesize
    • post_max_size - needs to be larger than upload_max_filesize
        $POST_MAX_SIZE = ini_get('post_max_size');
        $unit = strtoupper(substr($POST_MAX_SIZE, -1));
        $multiplier = ($unit == 'M' ? 1048576
            : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
    
        if (isset($_SERVER['CONTENT_LENGTH'])) {
            if ((int) $_SERVER['CONTENT_LENGTH'] > $multiplier * (int) 
              $POST_MAX_SIZE && $POST_MAX_SIZE) {
                $error = 'POST exceeded maximum allowed size.';
            }
        }
    
    • $_FILES['myfile']['error'] > 0 (see: http://php.net/manual/en/features.file-upload.errors.php)
    • File has no name / filename too long (value of $_FILES['myfile']['name'])
    • Trying to read a non-multipart upload, using multipart functions (E.G move_uploaded_file / is_uploaded_file returns false)
    • upload_tmp_dir not writeable (this is /tmp by default in linux)
    • Destination not writeable !is_writable($targetDir)
    • Disk full (although this usually gives UPLOAD_ERR_CANT_WRITE error)
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行