如何使用ajax将源src复制到文件夹 [英] how to copy the source src to folder using ajax
本文介绍了如何使用ajax将源src复制到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的html文件
<input type="submit" value="Submit" name="SUBMIT" id="btsubmit" onclick="getsrc()">
我的脚本
我选择了源路径
<form id="f1" name="form1" method="post">
var imagesrc = document.getElementById("ClonedElementX").src;
</form>
我的Ajax代码
i need to copy the source path to targeted path using ajax
$('#btsubmit').change(function() {
$(imagesrc).ajaxForm({ target: "C:\Users\Bhargavi\workspace\HTML\storedimage" }).submit();
return false;
});
我是ajax的新手,请帮助我我在此操作中做错的事情
I am new to ajax please help me what i did wrong in this
推荐答案
我没有检查过.但是类似的事情可能会帮你...:)
I have'nt checked this.But something like this might do it for you... :)
html
<div id='preview'></div>
<form id="imageform" method="post" enctype="multipart/form-data" action='ajaximage.php'>
<input type="file" name="photoimg" id="photoimg" />
</form>
脚本文件
$('#photoimg').live('change', function()
{
$("#imageform").ajaxForm({target: '#preview', //Shows the response image in the div named preview
success:function(){
},
error:function(){
}
}).submit();
});
ajaximage.php
ajaximage.php
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
{
$name = $_FILES['photoimg']['name'];
$size = $_FILES['photoimg']['size'];
$tmp = $_FILES['photoimg']['tmp_name'];
$path = "uploads/";
move_uploaded_file($tmp, $path.$name) //Stores the image in the uploads folder
}
这篇关于如何使用ajax将源src复制到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文