uploadify Multiple upload Image plugin

Source: Internet
Author: User

Website Demo Link: http://www.uploadify.com/demos/
Html:

<div class= "Dp_jtxx" > <span class= "bq_lf bq_sc" > image photo </span> <span class= "input-f Ile SC1 "> <input type=" file "id=" Shop_image "multiple=" true "/> </span> &l T;/div>

Need to introduce the JS, CSS:

<link type= "Text/css" rel= "stylesheet" href= "/public/uploadify/uploadify.css" ><script type= "text/ JavaScript "src="/public/uploadify/jquery-1.8.2.min.js "></script><script type=" Text/javascript "src=" /public/uploadify/jquery.uploadify.min.js "></script>

JS Code Processing:

$ (function () {    $ (' #shop_image '). Uploadify ({          ' formData ': {             ' <?php  echo session_name ();? > ':  ' <?php echo session_id ();? > '         },         ' Filetypedesc ':  ' upload file ',  //upload description          ' filetypeexts ':  ' { $set ['         filetype  ']} ',          ' swf ':  ' __home__/uploadify/uploadify.swf ',         ' Uploader ':  ' {: U (' Auth_image ')} ',//Background processing picture path          ' ButtonText ':   ' & #xe642; ',         ' buttonclass ': ' Hui-iconfont ',          ' filesizelimit ': &NBSP; ' 20000000KB ',         ' uploadlimit ':  5,  //file allows uploading quantity           ' width ': 120,         ' height ' : 40,         ' MarginLeft ':150,          ' Multi ':  true,//false not allowed to upload multiple images          ' auto ':  true,         ' buttoncursor ':  ' hand ',          ' uploadlimit '  : 3, //Allow uploading of files           ' Queueid '   :  ' some_file_queue ',         ' Successtimeout ':  10,  //wait for server response time          ' removetimeout ':  0.2,  //successfully show time          ' Onfallback ': function () {      &nbSp;      alert ("You can't upload a picture without the Flash control installed!") Please install the Flash control and try again. ");        },         ' Onuploadsuccess ':  function (file, data, response)  {             //alert (data)              data = $.parsejson (data);             var Image =  "             <input type= ' hidden '  name= ' auth_image[] '  id= '  value= '  + data.imgpath +  '  />              <a style= ' Position:absolute; Top:50px;right: 100px; '  thumbpath= '  + data.thumbpath +  '  imgpath= ' " + data.imgpath +   "'  href= ' javascript:; '   class= ' del ' >X</a> ';             if ($ ("A[class=del]"). length>=3) {                 alert ("No support for 3 or more!") ");            }else{                 $ (". Sc1"). Append (Image);             }        } (&NBSP;&NBSP;&NBSP;&NBSP;});}) Delete Picture  $ (function   ()  {        $ (". Del"). Live (' Click ',function   ()  {             var path       = $ (This). attr (' Imgpath ');             var thumbpath  = $ (This). attr (' Thumbpath ');             var del         = $ (this);             del.parent (). Find ("img"). Remove ();             del.parent (). Find (" Input "). Remove ();             del.remove ();         })     })

PHP Background processing picture returns JSON data:

Public function auth_image () {     $upload  = new \think\upload ();      $upload->exts      =  array (' jpg ',  ' GIF ',  ' png ',  ' jpeg ');     $upload->rootpath  =   './Uploads /';     $upload->savepath  =   '/image/auth/';     if  (!is_dir ($upload->savepath))     {         mkdir ($upload->savepath,0777,true);    }     $info   =  $upload->upload ();     if (! $info)  {         echo json_encode ($upload->geterror ());    }else{         //  upload Success          $info [' Filedata '] [' Savepath '] = str_replacE (' image ',  ' uploads/image ',  $info [' Filedata '] [' Savepath ']);          $path  =  $info [' Filedata '] [' Savepath '] .  $info [' Filedata '] [' Savename '];          $image  = new \think\image ();          $image->open ('. '). $path);         $thumbpath  =  '. $info [' Filedata '] [' Savepath '] .  $info [' Filedata '] [' Savename '];          $image->thumb (140, 84)->save ($thumbpath);          $path  = ltrim ($path, '. ');          $thumbpath  = ltrim ($thumbpath, '. ');          $data  = array (              ' Imgpath '  => $path,              ' Thumbpath '  =>  $thumbpath          )         echo json_encode ($data);     }}


uploadify Multiple upload Image plugin

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.