php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66082 Big files upload problem
Submitted: 2013-11-12 16:28 UTC Modified: 2013-12-05 16:49 UTC
From: nemesiz at nmz dot lt Assigned: mike (profile)
Status: Closed Package: *General Issues
PHP Version: 5.5.5 OS: linux debian 7 64 bit
Private report: No CVE-ID: None
 [2013-11-12 16:28 UTC] nemesiz at nmz dot lt
Description:
------------
OS - Ubuntu saucy
Browser - Google Chrome Version 30.0.1599.114

Server OS - Dedian 7 64bit

PHP - 5.5.5 FPM
Web server - Apache 2.4.6 with fastcgi module
Web server2 - nginx/1.4.1

PHP ini -
upload_max_filesize = 16G
post_max_size = 16G
max_input_time = -1
memory_limit = 512M

PHP compile -
'./configure' '--prefix=/usr/local/php/5.5.5' '--enable-cli' '--disable-cgi' '--enable-fpm' '--with-config-file-path=/usr/local/php/5.5.5/etc' '--with-config-file-scan-dir=/usr/local/php/5.5.5/etc/conf.d' '--enable-bcmath' '--enable-calendar' '--enable-ctype' '--enable-exif' '--enable-ftp' '--enable-intl' '--enable-mbstring=all' '--enable-zip' '--with-gd' '--with-jpeg-dir' '--with-png-dir' '--with-xpm-dir' '--with-t1lib' '--enable-gd-native-ttf' '--with-freetype-dir' '--enable-pcntl=shared' '--with-pcre-regex' '--with-pdo-mysql=mysqlnd' '--with-pdo-pgsql' '--disable-posix' '--enable-sockets=shared' '--with-zlib' '--with-bz2' '--with-curl=shared' '--enable-libxml' '--with-gettext' '--with-imap' '--with-imap-ssl' '--with-kerberos' '--with-mcrypt' '--with-mhash' '--with-mysql' '--with-mysqli=mysqlnd' '--with-openssl' '--with-pspell' '--enable-soap' '--with-tidy' '--with-xsl'


Upload test files

-rw-rw-r-- 1 nmz nmz  2097152000 Nov 12 17:17 2000
-rw-rw-r-- 1 nmz nmz  4194304000 Nov 12 17:49 4000
-rw-rw-r-- 1 nmz nmz  6291456000 Nov 12 17:54 6000


Apache sends POST data directly to PHP. Nginx saves first to self then send everything to PHP.

2GB file (2000) - OK
4GB file (4000) - OK
6GB file (6000) - PARTIAL

Browser send file OK. Server accept it too. PHP stop proceeding. 


Nginx example:

# lsof -p 24349
COMMAND   PID     USER   FD   TYPE             DEVICE   SIZE/OFF      NODE NAME
nginx   24349 www-data  cwd    DIR               0,92         30         4 /
nginx   24349 www-data  rtd    DIR               0,92         30         4 /
nginx   24349 www-data  txt    REG               0,92     592816   2230186 /usr/sbin/nginx
nginx   24349 www-data  mem    REG               0,47              2230186 /usr/sbin/nginx (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2157081 /lib/x86_64-linux-gnu/libnss_files-2.17.so (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2157077 /lib/x86_64-linux-gnu/libnss_nis-2.17.so (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2157053 /lib/x86_64-linux-gnu/libnsl-2.17.so (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2157059 /lib/x86_64-linux-gnu/libnss_compat-2.17.so (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2157095 /lib/x86_64-linux-gnu/libdl-2.17.so (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2157093 /lib/x86_64-linux-gnu/libc-2.17.so (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47                 9465 /lib/x86_64-linux-gnu/libz.so.1.2.8 (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2171351 /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2171352 /lib/x86_64-linux-gnu/libssl.so.1.0.0 (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2169146 /lib/x86_64-linux-gnu/libpcre.so.3.13.1 (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2157091 /lib/x86_64-linux-gnu/libcrypt-2.17.so (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2157096 /lib/x86_64-linux-gnu/libpthread-2.17.so (path dev=0,92)
nginx   24349 www-data  mem    REG               0,47              2157071 /lib/x86_64-linux-gnu/ld-2.17.so (path dev=0,92)
nginx   24349 www-data  mem    REG               0,97            119761855 (deleted)/dev/zero (stat: No such file or directory)
nginx   24349 www-data    0u   CHR                1,3        0t0   2227785 /dev/null
nginx   24349 www-data    1u   CHR                1,3        0t0   2227785 /dev/null
nginx   24349 www-data    2w   REG               0,92       5535    229807 /var/log/nginx/error.log
nginx   24349 www-data    3u  unix 0xffff88075744c440        0t0 119761857 socket
nginx   24349 www-data    4w   REG               0,92       6113    229806 /var/log/nginx/access.log
nginx   24349 www-data    5w   REG               0,92       5535    229807 /var/log/nginx/error.log
nginx   24349 www-data    6u  IPv4          119761854        0t0       TCP *:81 (LISTEN)
nginx   24349 www-data    7u  unix 0xffff8803fed77780        0t0 119761861 socket
nginx   24349 www-data    8u  unix 0xffff8803fed76dc0        0t0 119761863 socket
nginx   24349 www-data    9u  unix 0xffff8803fed77440        0t0 119761860 socket
nginx   24349 www-data   10u   REG                0,9          0      3866 anon_inode
nginx   24349 www-data   11u  IPv4          119775026        0t0       TCP 10.10.10.3:81->10.10.11.13:33475 (ESTABLISHED)
nginx   24349 www-data   12u   REG               0,92 6291456291    235481  (deleted)/var/lib/nginx/body/0000000002
nginx   24349 www-data   13u  unix 0xffff8801d540bac0        0t0 119784623 socket


root@web:/home/nmz/php/tmp# ls -lah php* && ls -la php*
-rw------- 1 nmz nmz 1.8G Nov 12 16:16 phppeElVl
-rw------- 1 nmz nmz 1867738816 Nov 12 16:16 phppeElVl

root@web:/home/nmz/php/tmp# ls -lah php* && ls -la php*
-rw------- 1 nmz nmz 1.9G Nov 12 16:16 phppeElVl
-rw------- 1 nmz nmz 1980361935 Nov 12 16:16 phppeElVl

root@web:/home/nmz/php/tmp# ls -lah php* && ls -la php*
ls: cannot access php*: No such file or directory

It stops to accept 6GB file then reach ~2GB

Test script:
---------------
<html><body>
<form action="" method="post" enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file"><br<input type="submit" name="submit" value="Submit"></form>

<?php
if (isset($_FILES["file"]) == true) {
	if ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br>"; }
	else {
		echo "Upload: " . $_FILES["file"]["name"] . "<br>";
		echo "Type: " . $_FILES["file"]["type"] . "<br>";
		echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
		echo "Stored in: " . $_FILES["file"]["tmp_name"];
	}
} else { echo "no file."; } ?>
</body></html>

Expected result:
----------------
Upload: 2000
Type: application/octet-stream
Size: 2048000 kB
Stored in: /home/nmz/php/tmp/phpLYRMee

Upload: 4000
Type: application/octet-stream
Size: -98304 kB
Stored in: /home/nmz/php/tmp/phphU3afJ

Upload: 6000
Type: application/octet-stream
Size: xxx kB
Stored in: /home/nmz/php/tmp/phpxxx

Actual result:
--------------
Upload: 2000
Type: application/octet-stream
Size: 2048000 kB
Stored in: /home/nmz/php/tmp/phpLYRMee

Upload: 4000
Type: application/octet-stream
Size: -98304 kB
Stored in: /home/nmz/php/tmp/phphU3afJ

Error: 3

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-12-05 16:49 UTC] mike@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: mike
 [2013-12-05 16:49 UTC] mike@php.net
Comes with 5.6
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Oct 31 22:01:27 2024 UTC