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
PHP and Mod_Fcgid: Ap_Pass_Brigade Failed in Handle_Request_Ipc Function
How to Retrieve Utf-8 Accented Characters from Access via Pdo_Odbc
PHP Array Behaving Strangely with Key Value 07 & 08
How to Create a Laravel Hashed Password
Codeigniter - How to Catch Db Errors
How to Get the Total Number of Rows of a Group by Query
PHP - Include a PHP File and Also Send Query Parameters
Connecting to Remote MySQL Server Using PHP
Algorithm That Will Take Numbers or Words and Find All Possible Combinations
Google Gcm Server Returns Unauthorized Error 401
Preg_Replace: Add Number After Backreference
Import File Size Limit in PHPmyadmin
Differencebetween Self::$Bar and Static::$Bar in PHP
Woocommerce: Add Product to Cart with Price Override