upload file jquery
hi my name is luca! im just a beginner with jquery and i completely stuck on uploading a file开发者_开发问答(or more) with jquery. Im actually trying to post a form (with input fields like "title","text"..plus the file upload one) with jquery and i can get all of the input file posted correctly in the $_POST array..but i have problems with the $_FILES one.
I'm using the Multiple File Upload plugin and as I read in the documentation i Just add the multi class to my file input element.
here it follows jquery little code:
$(document).ready(function(){
$(".submit").click(function(){
var title=$("#title").val();
var article=$("#article").val();
var images=$("#image").val();
var dataString="title="+title+"&article="+article+"images[]="+images;
$.ajax({
type: "POST",
url: "php/newPost.php",
data: dataString,
cache: false,
success: function(html){ //here i handle the received content
}
});
});
});
It is sending correctly everything except for the input file element..so please let me know how should i do.. I dont want to use iFrames and flash plugins =) thanks Luca
The first question that needs to be answered is do you have the following attribute applied to your form tag?
enctype="multipart/form-data"
精彩评论