javascript - JqueryFileUpload form url issue -
i try use jqueryfileupload plugin make ajax upload while form filling. have hard issue because need have different url in form params.
i use url param in jqueryfileupload object doesnt works if file input field located in form. uses form action url 'index.php?option=com_xxx&layout=edit&id=0' in .fileupload function instead of url 'index.php?option=com_xxx&task=item.uploadimage'.
how use ulr param in fileupload function , have file field inside form different action url? possible?
jquery code:
jquery('#jform_file').fileupload({ url: 'index.php?option=com_xxx&task=item.uploadimage', // element accept file drag/drop uploading dropzone: jquery('#drop'), // function called when file added queue; // either via browse button, or via drag/drop: add: function (e, data) { var tpl = jquery('<li class="working"><input type="text" value="0" data-width="48" data-height="48"'+ ' data-fgcolor="#0788a5" data-readonly="1" data-bgcolor="#3e4043" /><p></p><span></span></li>'); // append file name , file size tpl.find('p').text(data.files[0].name) .append('<i>' + formatfilesize(data.files[0].size) + '</i>'); // add html ul element data.context = tpl.appendto(ul); previewimage(data); // initialize knob plugin tpl.find('input').knob(); // listen clicks on cancel icon tpl.find('span').click(function(){ if(tpl.hasclass('working')){ jqxhr.abort(); } tpl.fadeout(function(){ tpl.remove(); }); }); // automatically upload file once added queue var jqxhr = data.submit(); }, progress: function(e, data){ // calculate completion percentage of upload var progress = parseint(data.loaded / data.total * 100, 10); // update hidden input field , trigger change // jquery knob plugin knows update dial data.context.find('input').val(progress).change(); if(progress == 100){ data.context.removeclass('working'); } }, fail:function(e, data){ // has gone wrong! data.context.addclass('error'); } });
form html:
<form action="index.php?option=com_xxx&layout=edit&id=0" method="post" name="adminform" id="adminform" class="form-validate"> <input type="file" name="jform[file]" id="jform_file" /> </form>
by accident found out solution. added 1 more fileupload call before right one:
jquery(function(){ jquery('#adminform').fileupload(); jquery('#jform_file').fileupload({ url: 'index.php?option=com_xxx&task=item.uploadimage', }); });
first 1 return form action url result can cause issues. second call returns result url param.
Comments
Post a Comment