以下是自学it网--中级班上课笔记
网址:www.zixue.it
引入的js包自己在网上找一个,这里好像不支持上传文件,反正我没找到,呵呵~~
html文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>swf文件上传</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<script type="text/javascript" src="./swf/swfupload.js"></script>
<script type="text/javascript">
// 写配置,就像.ini,.conf
var setting =
{
upload_url:'upfile.php', //后后接收的地址
flash_url: './swf/Flash/swfupload.swf', // swf上传插件主文件
file_post_name: 'pic',
file_types : "*.jpg;*.gif",// 限制文件类型
button_placeholder_id:'upload', // 插件初始化之后所占的对象位置
button_width:'200px',
button_height:'40px',
button_text:'请选择文件',
upload_success_handler : function(file,data) {
if(data == 'OK') {
alert('上传成功');
}
},
upload_progress_handler: function(file,complete,total) {
document.getElementById('progress').innerHTML = complete/total;
}
}; var swfu = null;
window.onload = function() {
// 页面加载完毕,就初始化swf对象
swfu = new SWFUpload(setting);
} </script> <style type="text/css">
</style>
</head>
<body>
<div id="progress"></div>
<div id="upload"></div>
<input type="button" value="上传" onclick="swfu.startUpload();" />
</body>
</html>
upfile.php
echo move_uploaded_file($_FILES['pic']['tmp_name'],'./upload/' . $_FILES['pic']['name']) ? 'OK':'fail';
如图: