<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv='Content-Type' content='text/html charset=utf-8' />
<title>File upload </title>
<link rel="Stylesheet" href="js/Plug-in/jquery.uploadify/uploadify.css" />
<script type="text/javascript" src="js/Plug-in/jquery.uploadify/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/Plug-in/jquery.uploadify/swfobject.js"></script>
<script type="text/javascript" src="js/Plug-in/jquery.uploadify/jquery.uploadify.v2.1.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#uploadify").uploadify({
'uploader': 'js/Plug-in/jquery.uploadify/uploadify.swf',
'script': 'uploadify.php',
'cancelImg': 'js/Plug-in/jquery.uploadify/cancel.png',
'folder': 'uploadfile',
'queueID': 'fileQueue',
'auto': false,
'multi': true,
})
})
</script>
</head>
<body>
MAX: 20M
</BR>
<input type="file" name="uploadify" id="uploadify" />
<a href="javascript:$('#uploadify').uploadifyUpload()">Upload</a>| <a href="javascript:$('#uploadify').uploadifyClearQueue()">cancel</a>
<div id="fileQueue"></div>
</body>
</html>
后台 uploadify.php
<?php/*
Uploadify v2.1.0
Release Date: August 24, 2009
Copyright (c) 2009 Ronnie Garcia, Travis Nickels
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name']
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']
$targetFile = iconv("utf-8","gbk",$targetFile)
move_uploaded_file($tempFile,$targetFile)
echo "1"
}
?>
可以用webuploader插件,上传成功后,服务端返回图片地址,客户端<img>显示图片
X关闭按钮这个得自己用css样式控制,点击X后,服务端删除图片,然后前端移除该X掉的图片