Good day all,
I'm developing a website with a form linked through PHP with MySQL. In the DDBB I have two tables, one with the records and the other with the uploaded filesnames attached to each record.
I'm trying that each time that a record is created or updated, the tbl_attachs is also updated.
I got it but independently, with a button to create/update the records, and adding to the PHP 'upload.php' the SQL INSERT query with the filename/size of the uploaded file.
But, I need to do it at the same time, I've hidden the 'Upload' button of the PLUPLOAD object with CSS, and added the method 'start' to the 'Save Record' button.
Code:
$("#btnSave").on("click",function() {
uploader.pluploadQueue('start');
saveRecord();
});
Uploader object code:
var uploader;
uploader = $("#uploader").pluploadQueue({
// General settings
multipart_params : {
"id" : $("#txtID").val()
},
runtimes : 'html5,html4',
url : '../PHP/upload.php',
max_file_size : '5mb',
rename: true,
dragdrop: true,
filters : [
{title : "Image files", extensions : "jpeg,jpg,gif,png"},
{title : "Compressed files", extensions : "zip,rar,7z"},
{title : "PDF files", extensions : "pdf"}
]
});
As mentioned, both function 'saveRecord()' and object 'uploader' works smoothly independently, and so the PHP code of 'upload.php' and 'saveRecord.php' is good.
So I think that the problem is with the event 'start' that is never executed, when I call it the only thing that happens is that the queue is cleared but never uploaded. Debugging the proyect, the PHP 'saveRecord.php' is executed not so with 'upload.php'
I've tried changing the execution order (first update the DDBB and then upload the files), changing 'uploader' with '$("#uploader")', changing '.pluploadQueue' with '.plupload' with no results. Even moving the function 'saveRecord()' to the event 'UploadComplete', but this event is not launched.
Any solution?
Thanks!