I want to write a client side script with a form where you can upload a large file (>2GB) to the server. The server would not be able to process such a big file with a regular html upload so the file has to be splitted in to multiple fileparts. Therefore my html form is:
<form enctype="multipart/form-data" method="post" id="fileinfo" name="fileinfo">
<label>Your email address:</label>
<input type="email" autocomplete="on" autofocus name="userid" placeholder="email" required size="32" maxlength="64" /><br />
<label>Custom file label:</label>
<input type="text" name="filelabel" size="12" maxlength="32" /><br />
<label>File to stash:</label>
<input type="file" name="file" required />
</form>
<a href="javascript:sendForm()">Stash the file!</a>
The jQuery is:
function sendForm() {
var fd = new FormData(document.getElementById("fileinfo"));
fd.append("CustomField", "This is some extra data");
$.ajax({
url: "stash.php",
type: "POST",
data: fd,
processData: false, // tell jQuery not to process the data
contentType: false, // tell jQuery not to set contentType
success: function(response){
console.log("Response was " + response);
},
failure: function(result){
console.log("FAILED");
console.log(result);
}
});
};
My php script is really short at the moment because I just wanted to test if it receives the form data:
if (isset($_POST['filelabel']) ) { var_dump('sent'); var_dump($_POST); }
But how to make "blobs" and set the size of the file parts? And how to proceed afterwards? Any tips, links or code snippets would be useful!