我正在处理图片上传页面。上传工作,但每当我点击提交,它将转到PHP页面。我已经返回false并设置了preventDefaut。有没有办法阻止它进入php页面?
我的HTML代码
<form action="imageupload.php" method="post" id="image_form"enctype="multipart/form-data">
<input id="update_image" name="file" type="file" maxlength="40">
<input id ="image_submit" type="submit" name="submit" value="Submit">
</form>
我的js代码
var options = {
target: "#output", // target element(s) to be updated with server response
// beforeSubmit: beforeSubmit, // pre-submit callback
resetForm: true // reset the form after successful submit
};
$("#image_form").submit(function(e) {
$(this).ajaxSubmit(options); //Ajax Submit form
// return false to prevent standard browser submit and page navigation
e.preventDefault();
return false;
});
答案 0 :(得分:2)
在没有看到您的代码的情况下真的无法告诉我,但我认为您正在寻找move_uploaded_file
move_uploaded_file($file,$newloc)
答案 1 :(得分:-1)
试试这个;
$path = '/path/to/files/';
$filename = 'name_you_want_to_give_upload';
$success = move_uploaded_file($tmp_name, $path . $filename);
参考:w3schools
祝你好运!