jquery - AJAX PHP file upload and parse example -


i looking take simple ajax form parses list of emails (via paste in textarea or csv file upload) , imports them mysql after validating them. here's html form:

<form id="form_parser" class="stylized">                 <div style="margin-bottom: 12px;">                     <h4>select software id:</h4>                     <select id="selectsoftid" name="selectsoftunlock">         <option value="190">putty</option><option value="356">filezilla</option>                        </select>                 </div>                  <div style="margin-bottom: 12px;">                     <h4>upload text/csv file:</h4>                     <input name="fileemails" type="file" id="inputfileemails">                     <input type="submit" class="button submit" value="">                 </div>                  <div>                     <h4>paste in emails:</h4>                     <div style="font-size: 12px; margin: -5px 0 6px;">(comma- or line-separated)</div>                 </div>                 <div class="textarea" style="margin-bottom: 4px;"><textarea name="txtemails"></textarea></div>                 <input type="submit" class="button submit" value="" id="btnsubmittxtemails">              </form> 

i wondering if knew of example online or provide on type of thing. love ajax response alert user how many emails imported. or links examples helpful. thank you!

i think can accomplished without ajax call.

when submit button clicked, call javascript function available in following link argument value of inputfileemails. function validate email addresses.

now, add following event in submit button.

onclick="checkemail(document.getelementbyid('inputfileemails').value);">

checkemail function available here:

http://code.activestate.com/recipes/578823-email-address-list-validation/

you may modify function per needs.

if require ajax call:

following link shows how send uploaded file target url using ajax call.

http://portfolio.planetjon.ca/2014/01/26/submit-file-input-via-ajax-jquery-easy-way/

in above link,

$.ajax( {

  url: 'urltovalidateemails.php',   type: 'post',   data: new formdata( ),   processdata: false,   contenttype: false } ); 

you may execute ajax inside function , call function using onsubmit event of button in form. or can use jquery execute ajax call (which available in link above).

here, using formdata object send data processing. can learn more formdata following link:

https://developer.mozilla.org/en-us/docs/web/api/formdata/using_formdata_objects

hope helps!


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -