I am trying to upload a file using jQuery ajax, but keep getting this error
“Could not convert JavaScript argument”
My code is
$.ajax({
contentType: "multipart/form-data",
url: "bll/uploadimage.php",
type: "get",
dataType: "html",
data:{imagefile:File},
error: function(){
jContent.html( "<p>Page Not Found!!</p>" );
},
beforeSend: function(){
$.blockUI();
},
complete: function(){
$.unblockUI({
onUnblock: function(){ }
});
},
success: function(data){
data = data.split(",");
document.getElementById("previewthumb94x94").src = data[0];
document.getElementById("filename").value = data[1];
}
});
where File is a file field retrieved by document.getElementbyID(“file”);
Please help, can’t get through.
You cannot do AJAX file uploads. Ajax is not supported but you can fake it by using iframe and css or you can use jquery file upload plugins.
you can try this:
Ajax File Upload Plugin
Multiple File Upload Plugin