javascript - Passing current data with ajaxform -



javascript - Passing current data with ajaxform -

i have form utilize upload images:

<form action="uploadimage.php" method="post" enctype="multipart/form-data" id="uploadform"> <input type="file" id="fileinput" name="imagefile" help_token="upload_token" size=20 /> <input type="submit" id="submitbutton" help_token="upload_token" value="upload" /> <img id="loadgif" src="images/ajax-loader.gif" alt="load gif" /> </form>

i prepare form ajaxform:

var statustxt = $('#statustxt'); var submitbutton = $("#submitbutton"); var myform = $("#uploadform"); var gallerystatus2$ = $("#gallerystatus2"); var error_code; $(myform).ajaxform({ // called when code loads info : {dstdir : g.currentgal}, // pass in $_post parameters resetform : true, beforesend: function() { //before submitting form gallerystatus2$.empty(); // clear status lastly upload submitbutton.attr('disabled', ''); // disable upload button $('img#loadgif').fadein(200); // start spinner }, complete: function(response) { // upload finish console.log("<br />upload complete. g.currentgal = " + g.currentgal); gallerystatus2$.html(response.responsetext); //upload status submitbutton.removeattr('disabled'); //enable submit button 1 time again $('img#loadgif').fadeout(200); // kill spinner

the problem i'm having want able tell action script, uploadimage.php, directory upload to. effort "data : {dstdir : g.gurrentgal}" line. g.currentgal holds lastly folder double-clicked, i.e., lastly folder opened , target uploads. ajaxform code runs when code loads initially, not when form submitted. g.currentgal whatever variable initialized when javascript first loads , never lastly folder opened. how can value of g.currrentgal @ time form submitted passed uploadimage.php in $_post array?

thanks

you need delete input submit, set button instead. on button click store info within hidden input tag. (with jquery or other) can submit form, obtain parameters setted on php page trought html form.

edit: said before submitting form relaunch g.storefolder each time folder opened.

javascript php jquery forms ajaxform

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -