javascript - C:\fakepath\*.* in Ajax, jquery -


i trying document able pass through ajax , jquery , keep getting c:\fakepath\ when attempting pass through. know security feature within browsers, haven't found way past it, passes doc. here's code, , jsfiddle. appreciated, can't figure out.

<form method="post" action="contact.php" name="contactform" id="contactform" enctype="multipart/form-data"> <label for="email" accesskey="e"><span class="required">*</span> fbn document</label> <input name="fbndoc" type="file" id="fbndoc" size="30" value="" /> 

jquery(document).ready(function () {  $('#contactform').submit(function () {      var action = $(this).attr('action');      var values = $.map($('[name^="attribute"]'), function (elem) {         return {             name: elem.name,             value: elem.value         };     });        $("#message").slideup(750, function () {         $('#message').hide();          $('#submit')             .after('<img src="assets/ajax-loader.gif" class="loader" />')             .attr('disabled', 'disabled');          $.post(action, {             firstname: $('#firstname').val(),             lastname: $('#lastname').val(),             email: $('#email').val(),             contactphone: $('#contactphone').val(),             values: $('values').val(),             fbn: $('#fbn').val(),             fbns: values,             fbnnumber: $('#fbnnumber').val(),             fbnaddress: $('#fbnaddress').val(),             fbncity: $('#fbncity').val(),             fbnstate: $('#fbnstate').val(),             fbnzip: $('#fbnzip').val(),             owneraddress: $('#owneraddress').val(),             ownercity: $('#ownercity').val(),             ownerstate: $('#ownerstate').val(),             ownerzip: $('#ownerzip').val(),             businesstype: $('#businesstype').val(),             otherfield: $('#otherfield').val(),             commencedate: $('#commencedate').val(),             fbndoc: $('#fbndoc').val(),             comments: $('#comments').val(),             form_type: $('#form_type').val(),              verify: $('#verify').val()         },          function (data) {             document.getelementbyid('message').innerhtml = data;             $('#message').slidedown('slow');             $('#contactform img.loader').fadeout('slow', function () {                 $(this).remove()             });             $('#submit').removeattr('disabled');             if (data.match('success') != null) $('#contactform').slideup('slow');          });      });      return false;  });  }); 

jsfiddle can found here: http://jsfiddle.net/g29wq/

you sending ajax filename, not content:

fbndoc: $('#fbndoc').val() 

if want upload file content ajax better use formdata, example jquery:

var fd = new formdata($('#fbndoc').get(0)); fd.append("customfield", "this data");//add data here $.ajax({   url: "stash.php",   type: "post",   data: fd,   processdata: false,  // tell jquery not process data   contenttype: false   // tell jquery not set contenttype }); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -