...

View Full Version : [JQuery] Get files using ajax!



sorlaker
03-31-2011, 11:47 AM
How can i get the file using jquery ajax?

body index


<div id="content"></div>
<input type="file" id="file" name="thefile" size="10"/>
<input id="uploadbutton" type="button" value="Upload"/>


js


$(document).ready(function() {
$("#uploadbutton").click(function() {
var filename = $("#file").val();
$.ajax({
type: "POST",
url: "upload.php",
data : {file : filename},
success: function(lol){
$('#content').html(lol);
}
});
});


});


upload.php file


echo $_FILES['file']['name'];


i can't deal with that red line code.

the php file only outputs : "Undefined variable: file in C:\wamp\www\upme\upload.php on line 4"

can u help me?

devnull69
04-01-2011, 08:29 AM
Take a look at "jQuery File Upload" on http://aquantum-demo.appspot.com/file-upload



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum