I m trying to upload large files using chunk upload. Gone through a few stack queries and found this code, However, it works perfectly fine for files below 200mb but when I try to upload say 2GB file, it returns This site can’t be reached - Connection was reset error page.
I know I missed the JS part which I couldn't able to figure it out.
HTML goes as :
<form action="upload.php" method="post" enctype="multipart/form-data">
<label>Upload Full Video</label>
<span class="pure-form-message"> * required</span>
<input type="file" name="video" class="file_multi_video" accept="video/*" id="stacked-email" style="width:60%;" placeholder="" />
</form>
Upload.php
set_time_limit(0);
$file2=($_FILES['video']['name']);
$tmpfile = $_FILES['file']['tmp_name'];
$orig_file_size = filesize($tmpfile);
$target_file = 'images/videos/'. $_FILES['video']['name'];
$chunk_size = 100; // chunk in bytes
$upload_start = 0;
$handle = fopen($tmpfile, "rb");
$fp = fopen($target_file, 'w');
while($upload_start < $orig_file_size) {
$contents = fread($handle, $chunk_size);
fwrite($fp, $contents);
$upload_start += strlen($contents);
fseek($handle, $upload_start);
}
fclose($handle);
fclose($fp);
unlink($_FILES['file']['tmp_name']);
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
php_value memory_limit 500M
php_value post_max_size 1000M
php_value upload_max_filesize 500M
Please help me out with the JS code for the above php chunk upload.
Any help is greatly appreciated.