php ajax无刷新上传图片实例代码
时间:2009-01-15 来源:militala
AJAX 客户端页面代码: index.html
[复制此代码]CODE:
<html>
<body>
<h1>Ajax file upload sample</h1><br/><input id="uplaod" name="btn_send" type="button" value="上传测试"/>
<div id=result></div>
<PRE class=js name="code">
</PRE>
</body>
</html> PHP服务器端代码: upload.php
[复制此代码]CODE:
<?php
// $_FILES['photofile']:是获得上传图片的数组
// $uploadfile:存放地址
$uploadfile = "D:/".$_FILES['photofile']['name'];
copy( $_FILES['photofile']['tmp_name'], $uploadfile );
echo "URL: <a href='http://localhost/".$_FILES['photofile']['name']."' target='_blank'>".$_FILES['photofile']['name']."</a><br/>";
?>
Upload successed! 本文来自: 脚本之家(www.jb51.net) 详细出处参考:http://www.jb51.net/article/15739.htm
[复制此代码]CODE:
<html>
<body>
<h1>Ajax file upload sample</h1><br/><input id="uplaod" name="btn_send" type="button" value="上传测试"/>
<div id=result></div>
<PRE class=js name="code">
</PRE>
</body>
</html> PHP服务器端代码: upload.php
[复制此代码]CODE:
<?php
// $_FILES['photofile']:是获得上传图片的数组
// $uploadfile:存放地址
$uploadfile = "D:/".$_FILES['photofile']['name'];
copy( $_FILES['photofile']['tmp_name'], $uploadfile );
echo "URL: <a href='http://localhost/".$_FILES['photofile']['name']."' target='_blank'>".$_FILES['photofile']['name']."</a><br/>";
?>
Upload successed! 本文来自: 脚本之家(www.jb51.net) 详细出处参考:http://www.jb51.net/article/15739.htm
相关阅读 更多 +