
Untitled
By: a guest on
Apr 24th, 2012 | syntax:
None | size: 1.19 KB | hits: 13 | expires: Never
File upload in php Ajax jQuery not working
<table>
<form name="profileimage" id="profileimage" method="post" enctype="multipart/form-data" >
<tr>
<td><img id="partner_pic" src="" height="100" width="100" /></td>
</tr>
<tr>
<td><input type="file" name="fileimg1" id="fileimg1" /></td>
</tr>
<tr>
<td><p id="pic_profile_p"></p></td>
</tr>
<tr>
<td><input type="submit" name="uploadimg" value="Change Picture" /></td>
</tr>
</form>
</table>
<?php
$target = "upload/";
$target = $target . $_FILES['fileimg1']['name'] ;
$ok=1;
if(move_uploaded_file($_FILES['fileimg1']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
}
else {
echo "Sorry, there was a problem uploading your file. <br />" . $_FILES['fileimg1']['error'];
}
?>
$("#profileimage").submit(function(){
var data = $(this).serialize();
$.post('ajx_upload.php', data, function(return_data){
$('#pic_profile_p').html(return_data)
});
return false;
});