Javascript 后期图像文件失败
我希望上载图像,但文件路径无法发布 我的表格:Javascript 后期图像文件失败,javascript,post,image-uploading,Javascript,Post,Image Uploading,我希望上载图像,但文件路径无法发布 我的表格: <form id="postIdeaForm" method="post" action="ideas.php" enctype="multipart/form-data"> <input name="selector" id="selector" type="file" style="position:absolute;width:200px;height:25px;display:none;" /> <div id
<form id="postIdeaForm" method="post" action="ideas.php" enctype="multipart/form-data">
<input name="selector" id="selector" type="file" style="position:absolute;width:200px;height:25px;display:none;" />
<div id="postIdeaBtn" class="alignRight postBtn pointer"><strong>post</strong></div>
</form>
但是看看控制台,我注意到文件没有发布,我做错了什么吗?您不能使用
ajax
发布文件,您需要使用,或者如果您不介意跨浏览器兼容性,请使用
$('#postIdeaBtn').click( function() {
$("#postIdeaForm").submit();
});
$("#postIdeaForm").validate({
errorElement:"div",
rules: {
dateIdea: "required"
},
messages: {
dateIdea: ""
},
submitHandler: function() {
$.post("ideas.php", $("#postIdeaForm").serialize(),
function(data) {
if(data == 'Success') {
window.location.href='date_ideas';
}
});
return false;
}
});