文件上传之SWFUpload插件代码

上传人:tang****xu7 文档编号:141737977 上传时间:2020-08-12 格式:DOCX 页数:7 大小:41.21KB
返回 下载 相关 举报
文件上传之SWFUpload插件代码_第1页
第1页 / 共7页
文件上传之SWFUpload插件代码_第2页
第2页 / 共7页
文件上传之SWFUpload插件代码_第3页
第3页 / 共7页
文件上传之SWFUpload插件代码_第4页
第4页 / 共7页
文件上传之SWFUpload插件代码_第5页
第5页 / 共7页
点击查看更多>>
资源描述

《文件上传之SWFUpload插件代码》由会员分享,可在线阅读,更多相关《文件上传之SWFUpload插件代码(7页珍藏版)》请在金锄头文库上搜索。

1、1前台文件index.html和2后台文件upload.php,需要的朋友可以参考下下面通过一段代码给大家演示下,主要分为1.前台文件index.html和2.后台文件upload.php。具体代码如下所示:代码如下:1.前台文件index.html& lt;!DOCTYPEhtml PUBLIC -/W3C/DTD XHTML 1.0 Tran siti on al/ENhttp:/www.w3.org/TR/xhtml1/DTD/xhtml1-tra nsitio nal.dtd >& lt;html xml ns=http:/www.w3.org/1999/xhtml >&

2、lt;meta http-equiv=Co nte nt-Type con te nt=text/html; charset=gb2312 />& lt;head >& t;title>SWFUpload</title><li nk href=css/default.css rel=stylesheet type=text/css />&t;!-Swfupload 插件 begin-><script type=text/javascript src=swfupload/swfupload.js></script><s

3、cript type=text/javascript src=js/swfupload.queue.js ></script><script type=text/javascript src=js/fileprogress.js > ;</script><script type=text/javascript src=js/ha ndlers.js > ;</script>&t;!-Swfupload 插件 end-><script type=text/javascript >var swfu;win dow. o

4、nl oad = function。var sett ings = flash_url : swfupload/swfupload.swf,upload_url: upload.php, / 后台文件post_params: PHPSESSID : <?php echo session_id(); ?>,file_size_limit : 100 MB,file_types : *.*,file_types_descripti on : All Files,file_uploadimit : 100,file_queue_limit : 0,custom_sett ings : p

5、rogressTarget : fsUploadProgress,can celButto nld : bt nCan cel,debug: false,/按钮设置button_image_url: images/TestlmageNoText_65x29.p ng, / Flash 样式图片文件 button_width: 65,button_height: 29,butt on _placeholder_id: spa nButt on PlaceHolder,button_text: <span class=theFont>浏览 </span>,button_te

6、xt_style: .theFo nt fon t-size: 16; , button_text_left_paddi ng: 12, butt on _text_top_padd ing: 3,/句柄设置file_queued_ha ndler : fileQueued,file_queue_error_ha ndler : fileQueueError,file_dialog_complete_ha ndler : fileDialogComplete, upload_start_ha ndler : uploadStart,upload_progress_ha ndler : uplo

7、adProgress, upload_error_ha ndler : uploadError, upload_success_ha ndler : uploadSuccess, upload_complete_ha ndler : uploadComplete, queue_complete_ha ndler : queueComplete;swfu = new SWFUpload(sett in gs);& lt;/script ></head >& lt;body >& lt;div id=header>& It;h1 id=logo>& lt;a h

8、ref=/>SWFUpload</a > ;& It;/h1 >& lt;div id=versio n>v2.2.0 & lt;/div></div>& lt;div id=co nte nt ><form id=form1 action=i ndex.php method=post en ctype=multipart/form-data><p>点击“浏览”按钮,选择您要上传的文档文件后,系统将自动上传并在完成后提示您。</p ><p>请勿上传包含中文文件名的文件!</p>& l

9、t;div class=fieldset flash id=fsUploadProgress><span class=legend>快速上传 </span></div><div id=divStatus>O个文件已上传 </div>& t;div>& lt;span id=spa nButto nPlaceHolder></spa n>& lt;i nputid=bt nCan celtype=butt onvalue=取消所有上传”on click=swfu.ca ncelQueue(); disabl

10、ed=disabled style=margi n-left: 2px; fon t-size: 8pt; height: 29px; /></div></form ></div>& lt;divalig n=ce nter>Ha nizati onBy&t;ahref=http:/imll. nettarget=_bla nk >Leo.C,</a ></div>& t;/body >& lt;/html>2后台文件 upload.php<?php/传递session值(由于Flash与sessi

11、on不兼容,只能通过参数传递获取)if (isset($_POSTPHPSESSID) session_id($_POSTPHPSESSID); else if (isset($_GETPHPSESSID) session_id($_GETPHPSESSID);sessi on _start();/设置POST最大值$POST_MAX_SIZE = in i_get(post_max_size);$un it = strtoupper(substr($POST_MAX_SIZE, -1);$multiplier = ($un it = M ? 1048576 : ($unit = K ? 10

12、24 : ($un it = G ? 1073741824 : 1);if (i nt)$_SERVERCONTENT_LENGTH& gt; $multiplier*(i nt)$POST_MAX_SIZE& amp; & $POST_MAX_SIZE) header(HTTP/1.1 500 In ternal Server Error); echo POST exceeded maximum allowed size.; exit(0);/基本设置$save_path = getcwd() . /file/;/ 文件上传位置$upload_ name = Filedata;$ma

13、x_file_size_in_bytes = 2147483647;/ 2GB$exte nsion_whitelist = array(doc, txt, jpg, gif, pn g); / 允许文件类型$valid_chars_regex = .A-Z0-9_ !#$%NAME_LENGTH = 260;$file_ name =;$file_exte nsion =;$uploadErrors = array(0=>文件上传成功,仁>上传的文件超过了php.ini文件中的 upload_max_filesize directive 里的设置,2=>上传的文件超过了HT

14、ML form 文件中的 MAX_FILE_SIZE directive 里的设3=>上传的文件仅为部分文件,4=>没有文件上传,6=>缺少临时文件夹”);/检测文件是否上传正确if (!isset($_FILES$upload_name) Han dleError(No upload found in $_FILES for . $upload_ name); exit(0);elseif(isset($_FILES$upload_ nameerror)& amp;&$_FILES$upload_ nameerro门!= 0) Han dleError($uploadErrors$_FILES$upload_ nameerror); exit(O);elseif(!isset($_FILES$upload_ nametmp_ name)| !is_uploaded_file($_FILES$upload_ nametmp_ name) Han dleError(Upload failed is_uploaded_file test.);exit(0); else if (!isset($_FILES$upload_ name name) Han dleErr

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号