Home >php教程 >php手册 >Thinkphp 3.2.2 整合Swfupload上传插件

Thinkphp 3.2.2 整合Swfupload上传插件

WBOY
WBOYOriginal
2016-06-07 11:40:341379browse

Thinkphp 3.2.2 整合Swfupload上传插件
做程序开发的人,基本上都知道SWFUpload是个文件上传利器,SWFUpload是一个flash和js相结合而成的文件上传插件,其功能非常强大。THINKPHP又是现在国内最流行的框架,两者的强

强联合是必然的,下面脚本100 就给大家实例讲解Thinkphp 3.2.2 整合Swfupload上传插件。
1、先从网上下载一个SWFUpload插件;
2、将SWFUpload插件复制到Public公用文件夹内;
3、将SWFUpload插件引入所需要的页面;

HTML代码:<script></script><br> <script></script><br> <script></script>    <br> <script><br /> var swfu;<br /> window.onload = function () {<br /> swfu = new SWFUpload({<br /> upload_url: "__URL__/uploadImg", //处理上传文件方法<br /> post_params: {"PHPSESSID": "<?php echo session_id();?>"},<br /> file_size_limit : "40 MB",<br /> file_types : "*.jpg;*.png;*.gif;*.bmp,*.psd;",<br /> file_types_description : "JPG Images",<br /> file_upload_limit : "100",<br /> file_queue_error_handler : fileQueueError,<br /> file_dialog_complete_handler : fileDialogComplete,<br /> upload_progress_handler : uploadProgress,<br /> upload_error_handler : uploadError,<br /> upload_success_handler : uploadSuccess,<br /> upload_complete_handler : uploadComplete,<br /> button_image_url : "__PUBLIC__/Swfupload/images/upload.png",<br /> button_placeholder_id : "spanButtonPlaceholder",<br /> button_width: 113,<br /> button_height: 33,<br /> button_text : &#039;&#039;,<br /> button_text_style : &#039;.spanButtonPlaceholder { font-family: Helvetica, Arial, sans-serif; font-size: 14pt;} &#039;,<br /> button_text_top_padding: 0,<br /> button_text_left_padding: 0,<br /> button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,<br /> button_cursor: SWFUpload.CURSOR.HAND, <br /> flash_url : "__PUBLIC__/Swfupload/swf/swfupload.swf",<br /> custom_settings : {<br /> upload_target : "divFileProgressContainer"<br /> }, <br /> debug: false<br /> });<br /> }; <br /> </script><br> <br> <div></div> <br>  <div> <br> <ul> <br> <li> <br>  </li> <li> <br> <div></div> <br>  </li> <br>  </ul> <br> </div>     上传文件处理方法    //swfupload上传插件<br>     public     function uploadImg() {<br>         import('ORG.Net.UploadFile');<br>         $upload = new \ORG\Net\UploadFile();// 实例化上传类<br>         $upload->maxSize  = 3145728 ;// 设置附件上传大小<br>         $upload->allowExts  = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型<br>         $savepath='./Uploads/image/'.date('Ymd').'/';<br>         if (!file_exists($savepath)){<br>             mkdir($savepath);<br>         }<br>         $upload->savePath =  $savepath;// 设置附件上传目录<br>         if(!$upload->upload()) {// 上传错误提示错误信息<br>             $this->error($upload->getErrorMsg());<br>         }else{// 上传成功 获取上传文件信息<br>             $info =  $upload->getUploadFileInfo();<br>         }<br>         $str=WEB_PATH.'/'.$info[0]['savepath'].'/'.$info[0]['savename'];<br>         print_r(str_replace("./", "", $str));<br>     }Swfupload上传插件下载地址,请查看http://www.jb100.net/html/content-28-300-1.html

请继续关注我,我会继续给大家分享更多的代码案例

AD:真正免费,域名+虚机+企业邮箱=0元

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn