0

我的 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 新手,请帮助我在这方面做错了什么

4

1 回答 1

0

我没有检查过这个。但是这样的事情可能会为你做...... :)

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

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
}
于 2013-10-07T10:22:20.940 回答