I want to chunk upload multiple files with form data. Save form data to database and image to a perticualr folder.
I'm using blueimp upload here is my Fiddle.
The JavaScript codde i'm using
$(function () {
$('#fileupload').fileupload({
maxChunkSize: 5000,
previewMaxHeight: 210,
previewMaxWidth: 210,
url: '/echo/json'
});
$('#fileupload').bind('fileuploadsubmit', function (e, data) {
var inputs = data.context.find(':input');
if (inputs.filter('[required][value=""]').first().focus().length) {
return false;
}
data.formData = inputs.serializeArray();
});
});
Chunk upload is working fine, but if I save data to database multiple entries are created. The number of entries created in database is equal to number chunk uploaded.
The PHP code that i'm using is ( taking help of blueimp PHP class https://github.com/blueimp/jQuery-File-Upload/blob/master/server/php/UploadHandler.php )
public function postUpload()
{
$upload_handler = new UploadHandler(); // Blueimp class
$this->file->create(Input::all()); // This code is executed multiple times
}
So main trouble is $this->file->create(Input::all());
code is execute multiple times as the number of chunks uploaded, where as I want it to be executed once when file is uploaded successfully.
Also want to name file of the file that is uploaded to save it to database.