下载免费的Uploadify包 :http://www.uploadify.com/downloads
jquery版本1.4+
<script src="jquery.js"></script>
<script src="jquery.uploadify-3.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="uploadify.css" />
页面中
<input type="file" name="file_upload" id="file_upload" />
<button class='start'>start</button>
<div id="show"></div>
js
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'swf' : 'uploadify.swf',
'uploader' : 'uploadify.php',
'auto' : false, // 是否自动上传
'buttonText' : '上传文件', //改按钮名字
//'width' : '300',
//'height' : '200',
'onUploadSuccess' : function(file,data,response){ //上传后显示,这个要改uploadify里面输出内容
html="<p><img src='"+data+"'></p>";
$('#show').append(html);
},
});
$('.start').click(function() { //点击按钮才上传
$('#file_upload').uploadify('upload','*');
})
});
</script>
uploadify
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'swf' : 'uploadify.swf',
'uploader' : 'uploadify.php',
'auto' : false, // 是否自动上传
'buttonText' : '上传文件', //改按钮名字
//'width' : '300',
//'height' : '200',
'onUploadSuccess' : function(file,data,response){ //上传后显示,这个要改uploadify里面输出内容
html="<p><img src='"+data+"'></p>";
$('#show').append(html);
},
});
$('.start').click(function() { //点击按钮才上传
$('#file_upload').uploadify('upload','*');
})
});
</script>