1
我想从JQuery模式中上传图像。形式隐藏在PHP和一旦链接被点击出现的模态窗口,有一个非常简单的形式一起,只是一个文件上传字段
<form action="" method="post" enctype="multipart/form-data" id="uploadprofileimage" name="uploadprofileimage">
<label for="image">Upload a picture of the item:</label>
<input type="file" name="image" id="image">
</form>
然而,当上传按钮被点击的形式是序列化和发送。要尝试解决此问题,我已回发到该页面,并且在转储$ _POST和$ _FILES时数组为空,我在哪里出错?当我将变量发布到PHP时,我已经完成了发布,但由于某种原因,我无法发布表单!
下面是我的jQuery代码,希望有人能帮助!感谢
$("[href='#avatar']").click(function() {
$("#profile-upload").dialog({
title: 'Add a profile image',
width: 400,
height: 200,
buttons:[
{
text: 'Upload',
click: function(e) {
e.preventDefault();
var post = $("#uploadprofileimage").serialize();
$.post("profiles.php", post, function(data){
console.log(post);
console.log(data);
},'json');
}
},
{ text: 'Close', click: function() { $(this).dialog('close');}}
]
});
});
非常感谢蒂姆,我想我会让PHP处理文件上传! – Alan 2012-03-23 22:43:47