Home >php教程 >php手册 >PHP personal center avatar upload demonstration and download

PHP personal center avatar upload demonstration and download

WBOY
WBOYOriginal
2016-07-06 13:29:161121browse

To implement the steps, introduce the plupload upload plug-in and set multi_selection to single file upload.
PHP personal center avatar upload demonstration and download
Upload avatar code: var uploader_avatar = new plupload.Uploader({//Construction method to create an instance <code class="prettyprint linenums lang-php">var uploader_avatar = new plupload.Uploader({//创建实例的构造方法 <br>     runtimes: 'gears,html5,html4,silverlight,flash', //上传插件初始化选用那种方式的优先级顺序 <br>     browse_button: ['avatar_uplpad_btn'], // 上传按钮 <br>     url: "ajax.php", //远程上传地址 <br>     flash_swf_url: 'js/plugins/plupload/Moxie.swf', //flash文件地址 <br>     silverlight_xap_url: 'js/plugins/plupload/Moxie.xap', //silverlight文件地址 <br>     filters: { <br>         max_file_size: '10mb', //最大上传文件大小(格式100b, 10kb, 10mb, 1gb) <br>         mime_types: [//允许文件上传类型 <br>             {title: "files", extensions: "jpg,png,gif,jpeg"} <br>         ] <br>     }, <br>     multi_selection: false, //true:ctrl多文件上传, false 单文件上传 <br>     init: { <br>         FilesAdded: function(up, files) { //文件上传前 <br>  <br>             uploader_avatar.start(); <br>         }, <br>         UploadProgress: function(up, file) { //上传中,显示进度条 <br>             var percent = file.percent; <br>             $("#"   file.id).find('.bar').css({"width": percent   "%"}); <br>             $("#"   file.id).find(".percent").text(percent   "%"); <br>         }, <br>         FileUploaded: function(up, file, info) { //文件上传成功的时候触发 <br>             var data = eval("("   info.response   ")");//解析返回的json数据 <br>             $("#avatar_pic").html("<img src=&#039;" data.pic "&#039;/>") <br>         }, <br>         Error: function(up, err) { //上传出错的时候触发 <br>             alert(err.message); <br>         } <br>     } <br> }); <br> uploader_avatar.init(); Runtimes: 'gears,html5,html4,silverlight,flash', //The priority order of upload plug-in initialization method

​​browse_button: ['avatar_uplpad_btn'], // Upload button

URL: "ajax.php", //Remote upload address

Flash_swf_url: 'js/plugins/plupload/Moxie.swf', //flash file address Silverlight_xap_url: 'js/plugins/plupload/Moxie.xap', //silverlight file address Filters: {          max_file_size: '10mb', //Maximum upload file size (formats 100b, 10kb, 10mb, 1gb)           mime_types: [//Allow file upload types {title: "files", extensions: "jpg,png,gif,jpeg"} ] }, Multi_selection: false, //true:ctrl multi-file upload, false single file upload init: { FilesAdded: function(up, files) { //Before uploading files                  uploader_avatar.start();         }, UploadProgress: function(up, file) { //Uploading, display progress bar                    var percent = file.percent;  $ ("#" File.id) .find ('. Bar'). CSS ({"width": percent "%"}); $ ("#" File.id) .find (". Percent"). Text (percent "%");         }, FileUploaded: function(up, file, info) { //Triggered when file upload is successful           var data = eval("(" info.response ")");//Parse the returned json data               $("#avatar_pic").html("")          }, ​​​​ Error: function(up, err) { //Triggered when an upload error occurs alert(err.message);          }  }   }); uploader_avatar.init();Online upload avatar demonstration: http://www.sucaihuo.com/js/880.html Cloud Conference Beijing Station: Alibaba technical experts rarely make an appearance, this time they are here More than 100 people? !
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