I need your help. I want to create a upload script with HTML, JQuery and PHP. Is it possible to write a script, that can upload very large files(> 5 GB)?
I've try it with FileReader, FormData and Blobs, but even with these, i can't upload large files(my browser crashes after selecting a large file).
PS: I want to write it myself. Don't post any finished scripts.
Regards
Yes. I wrote PHP to upload file exactly 5GB more then one year ago.
FileReader, FormData and Blobs will fail because they all require pre-process and convert in javascript before it get upload.
But, you can easily upload large file with plain simple XMLHttpRequest.
var xhr=new XMLHttpRequest();
xhr.send(document.forms[0]['fileinput']);
It is not a standard or documented way, however, few Chrome and Firefox do support. However, it send file content as is, not multipart/form-data, not http form-data. You will need to prepare your own http header to provide additional information.
var xhr=new XMLHttpRequest(), fileInput=document.forms[0]['fileinput'];
xhr.setRequestHeader("X-File-Name", encodeURIComponent(getInputFileName(fileInput)));
xhr.setRequestHeader("X-File-Size", getFileSize(fileInput));
xhr.send(fileInput);
PS. well, actually it was not PHP. It was mixed PHP and Java Servlet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With