`No such file` error after uploading large files with 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 sma开发者_开发知识库ll 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!
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)
Have you checked your server LimitRequestBody parameter ? It may not be high enough for the files you're trying to upload.
Have you verified your php upload_max_filesize and post_max_size settings? (in your php.ini file)
Once the upload is finished, there is a standard information in the $_FILES array showing there are no errors.
I'm assuming you checked the error
element? It's an integer that corresponds to one of the upload error constants, such as UPLOAD_ERR_INI_SIZE
.
As I understand it, UPLOAD_ERR_NO_FILE
can also be returned if the file size goes over the PHP post_max_size
or some Apache limit (Arkh mentioned LimitRequestBody
)
Side Note: Ubuntu 10.04 LTS is out now
精彩评论