jquery fileupload formData input name -
i using jquery fileupload , want pass input name of file in formdata , have try fails.
i try use this.name seems dont have access of in formdata
formdata : { action:'upload', field:this.name , extensions : 'gif|jpeg|jpg|png'}
i have try use data attributes dont post in case
<input id="input-image2" class="file-upload" type="file" name="image2" data-form-data='{ action:'upload', field:image2 , extensions : 'gif|jpeg|jpg|png'}' >
does know how add input name (in case image2) formdata?
the fileupload init follows
and need fill field param of formdata name of input file image2
$('.file-upload').fileupload({ url: '/myfile.php', formdata : { action:'upload', field:this.name , extensions : 'gif|jpeg|jpg|png'}, acceptfiletypes: /(\.|\/)(gif|jpeg|jpg|png)$/i, add : function (e, data) { var type=data.files[0].type; var size=data.files[0].size; var name=data.files[0].name; if(type=="image/gif" || type=="image/jpg" || type=="image/jpeg" || type=="image/png") { data.submit(); } else { //data.submit(); alert('please upload .gif, .jpeg, .jpg .png files'); } }, fail: function(e, data){ alert(data.jqxhr.responsetext); }, datatype: 'json', done: function (e, data) { //code here }, progressall: function (e, data) { var progress = parseint(data.loaded / data.total * 100, 10); $('#progress .progress-bar').css( 'width', progress + '%' ); } }).prop('disabled', !$.support.fileinput) .parent().addclass($.support.fileinput ? undefined : 'disabled');
any appriciated. thanks
just access input
element id
, use attr
function on name attribute:
formdata : { action:'upload', field:$("#input-image2").attr("name"), extensions : 'gif|jpeg|jpg|png'};
Comments
Post a Comment