PHP copy WeChat multi-image preview upload function

Source: Internet
Author: User
Tags silverlight
Production picture area, upload button #btn can replace the picture you want

[HTML] View plain copy
View code slices to my Code slice

<ul id= "Ul_pics" class= "Ul_pics clearfix" >       <li></li>   </ul>

Plupload Upload

[JavaScript] View plain copy
View code slices to my Code slice

var uploader = new Plupload. Uploader ({//Create instance Construction method runtimes: ' Html5,flash,silverlight,html4 ',//upload plugin initializes the order of precedence in that way Browse_button: ' btn ',/ /upload button URL: "ajax.php",//Remote upload address flash_swf_url: ' plupload/moxie.swf ',//flash file address Silverlight_xap_url: ' Plupload/moxie.xap ',//silverlight file address filters: {max_file_size: ' 10mb ',//MAX upload file size (format 100b, 10kb, 10MB, 1g       b) Mime_types: [//Allow file upload type {title: "Files", Extensions: "Jpg,png,gif,jpeg"}]}, Multi_selection:true,//true:ctrl multiple file upload, false single file upload init: {filesadded:function (up, files) {//File upload The previous if ($ ("#ul_pics"). Children ("Li"). Length > ("Alert" ("You've uploaded too many pictures!").                   ");               Uploader.destroy ();                   } else {var li = '; Plupload.each (Files, function (file) {//traversal file Li + = "<li id= '" + file[' id ') + "' ><p class= ' p Rogress ' ><span CLAss= ' Bar ' ></span><span class= ' percent ' >0%</span></p></li> ';                   });                   $ ("#ul_pics"). Prepend (LI);               Uploader.start ();               }}, Uploadprogress:function (up, file) {//on crosses, show progress bar var percent = file.percent;               $ ("#" + file.id). Find ('. Bar '). css ({"width": percent + "%"});           $ ("#" + file.id). Find (". Percent"). Text (Percent + "%"); }, Fileuploaded:function (up, file, info) {//File upload succeeds when uploading var data = eval ("(" + Info.response + ") ");//Parse the returned JSON data $ (" # "+ file.id). HTML (" <input type= ' hidden ' name= ' pic[] ' value= ' "+ data.pic +"/>&lt Input type= ' hidden ' name= ' pic_name[] ' value= ' "+ data.name +" '/>

Ajax to delete uploaded pictures

[JavaScript] View plain copy
View code slices to my Code slice

function Delpic (pic, file_id) {//delete picture parameter 1 picture path  parameter 2 random number       if (Confirm ("OK to delete? ") {           $.post (" del.php ", {pic:pic}, function (data) {               $ (" # "+ file_id). Remove ()}           )}   }


PHP Imitation multi-image Preview Download demo address: http://www.php.cn/
Production picture area, upload button #btn can replace the picture you want

[HTML] View plain copy
View code slices to my Code slice

<ul id= "Ul_pics" class= "Ul_pics clearfix" >       <li></li>   </ul>

Plupload Upload

[JavaScript] View plain copy
View code slices to my Code slice

var uploader = new Plupload. Uploader ({//Create instance Construction method runtimes: ' Html5,flash,silverlight,html4 ',//upload plugin initializes the order of precedence in that way Browse_button: ' btn ',/ /upload button URL: "ajax.php",//Remote upload address flash_swf_url: ' plupload/moxie.swf ',//flash file address Silverlight_xap_url: ' Plupload/moxie.xap ',//silverlight file address filters: {max_file_size: ' 10mb ',//MAX upload file size (format 100b, 10kb, 10MB, 1g       b) Mime_types: [//Allow file upload type {title: "Files", Extensions: "Jpg,png,gif,jpeg"}]}, Multi_selection:true,//true:ctrl multiple file upload, false single file upload init: {filesadded:function (up, files) {//File upload The previous if ($ ("#ul_pics"). Children ("Li"). Length > ("Alert" ("You've uploaded too many pictures!").                   ");               Uploader.destroy ();                   } else {var li = '; Plupload.each (Files, function (file) {//traversal file Li + = "<li id= '" + file[' id ') + "' ><p class= ' p Rogress ' ><span CLAss= ' Bar ' ></span><span class= ' percent ' >0%</span></p></li> ';                   });                   $ ("#ul_pics"). Prepend (LI);               Uploader.start ();               }}, Uploadprogress:function (up, file) {//on crosses, show progress bar var percent = file.percent;               $ ("#" + file.id). Find ('. Bar '). css ({"width": percent + "%"});           $ ("#" + file.id). Find (". Percent"). Text (Percent + "%"); }, Fileuploaded:function (up, file, info) {//File upload succeeds when uploading var data = eval ("(" + Info.response + ") ");//Parse the returned JSON data $ (" # "+ file.id). HTML (" <input type= ' hidden ' name= ' pic[] ' value= ' "+ data.pic +"/>&lt Input type= ' hidden ' name= ' pic_name[] ' value= ' "+ data.name +" '/>

Ajax to delete uploaded pictures

[JavaScript] View plain copy
View code slices to my Code slice

function Delpic (pic, file_id) {//delete picture parameter 1 picture path  parameter 2 random number       if (Confirm ("OK to delete? ") {           $.post (" del.php ", {pic:pic}, function (data) {               $ (" # "+ file_id). Remove ()}           )}   }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.