[英]upload form with image to ajax and php
我正在将图像上传到ajax并使用表单发送到php。但是我搜索了很多资源,但仍然不知道。有人可以帮助我完成代码吗?
<form name="registerform" id="data">
<div id="formleft">
<input type="email" name="email" placeholder="Email Address"><br>
<input type="file" id="pic" name="profile_pic" class="image_input" />
<input type="button" name="register" value="Sign Up" onclick="re2()" /><br>
</div>
</form>
function re2()
{
var image=document.getElementById("pic").src;
var re_email1=$("[name=register_email]").val();
$.ajax({
type : "get",
url : "add.php",
data : "type=regis2&image="+image+"&re_email="+email,
success : function(data){
alert(data);
*/ how i get the image file from form and pass the file to here and send ?? */
}
});
}
<?php
if ($_GET['type'] == "regis2")
{
$image=$_GET['image'];
$email=$_GET['re_email'];
$target_Path = 'image/';
$target_Path = $target_Path.basename( $_FILES['image']['name'] );
move_uploaded_file($_FILES["image"]["tmp_name"] , $target_Path);
}
?>
}
我如何使用ajax.image传递图像,因为我已通过Google搜索,但仍然不知道。 谁能为我完成代码? 真的需要很多帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.