Upload 1Gb Files Using Chunking in PHP

how to upload a large size file in chunks on server in php?

increase upload maximum file size limit with this method :

Method # 1: Edit php.ini

Edit your php.ini file (usually stored in /etc/php.ini or /etc/php.d/cgi/php.ini or /usr/local/etc/php.ini):

# vi /etc/php.ini

Sample outputs:

memory_limit = 32M
upload_max_filesize = 10M
post_max_size = 20M

Save and close the file. Restart apache or lighttpd web server:

service httpd restart

OR
service lighttpd restart

Method #2: Edit .htaccess

Edit .htaccess file in your root directory. This is useful when you do not have access to php.ini file. In this example, /home/httpd/html is considered as root directory (you can also create .htaccess file locally and than upload it using ftp / sftp / scp client):

# vi /home/httpd/html/.htaccess

Append / modify setting as follows:

php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 32M

Save and close the file.

Method #3: Edit PHP File

ini_set('upload_max_filesize', '10M');
ini_set('post_max_size', '10M');
ini_set('max_input_time', 300);
ini_set('max_execution_time', 300);

After this you can ckeck :

<?php
phpinfo();
?>

check this for chunk upload
plupload

AJAX/PHP - Upload a large file in segments in pure javascript

I forgot that I had to use

xhttp.setRequestHeader('Content-Type', 'application/octet-stream');

before sending to set the stream to be a blob. With this, I can now save the file using this PHP:

<?php
file_put_contents(time()+rand(), file_get_contents("php://input"));
?>

Of course this saves it into some random file, so if this helps anyone, please change the code to fit your needs



Related Topics



Leave a reply



Submit