---restore content starts---
Official website: http://www.uploadify.com/a good upload plugin. Official Document Http://www.uploadify.com/documentation/
Usage online a lot. Happy today I want to dynamically wear the selection in the project, and then upload, at the same time the server side, accept the parameters and pictures of the address. Uploadify, however, is the value that gets to the page before it is loaded. So I searched for a bit. Find the way. But all of them are old versions. Today I'm going to write a new 3.21 version.
Point 1, turn off automatic uploads. Red Place
$ (' #upload '). Uploadify ({swf:' __public__/uploadify/uploadify.swf ', uploader:' __app__/home/word/upload ', Width:120, Height:30, Auto: false , filetypedesc:' Image File ', Filetypeexts:' *.jpeg; *.jpg; *.png; *.gif ', FormData: {' session_id ': Sid}, Onuploadsuccess:function(file, data, response) {alert (data); } });
2, using manual upload before, set the settings fromdata such as my project's wording
<a class= "btn btn-success" href="javascript:$ (' #upload '). Uploadify (' Settings ', ' FormData ', {' type ': $ ('. Prov '). Val (), ' City ': $ ('. City '). Val ()}); $ (' #upload '). Uploadify (' upload ') "> Start uploading </a>
I am using PHP, using the thinkphp framework back-end processing image code is also affixed:
Public function upload () {if (!is_post) {$this-error (' page does not exist '); }//P ($_post);d ie; $upload = $this->_upload (); }/** * Process image upload */Private function _upload () {$upload = new \think\upload ();//instantiation of upload class $upload->maxsize = 3145728;//Set attachment upload size $upload->exts = array (' jpg ', ' gif ', ' PNG ', ' JP eg ');//Set attachment upload type $upload->rootpath = './uploads/'; Set the attachment upload root directory $upload->uploadrepace = true; Overwrite the same name $upload->thunb = true; Thumbnail processing $upload->thunbmaxwidth =90;//thumbnail width $upload->thunbmaxheight =60;//thumbnail height $upload->th Unbprefix = ' mini_ ';//thumbnail prefix//$upload->savepath = '; Set attachments Upload (sub) directory//upload file $info = $upload->upload (); if (! $info) {//Upload error error message return array (' status ' = 0, ' msg ' = $this->error ($upload->geterror ())); }else{//Upload Success foreach ($info as $file) {return $file [' Savepath ']. $file [' Savename ']; } $this->success (' Upload successful! ‘); }}}//Picture watermark function Mark_pic ($background, $waterpic, $x, $y) {$back =imagecreatef Romjpeg ($background); $water =imagecreatefromgif ($waterpic); $w _w=imagesx ($water); $w _h=imagesy ($water); Imagecopy ($back, $water, $x, $y, 0, 0, $w _w, $w _h); Imagejpeg ($back, "__public__/images/hee8.jpg"); Imagedestroy ($back); Imagedestroy ($water); }//Mark_pic ("./images/hee.jpg", "./images/gaolf.gif", 50, 200); Image Plus text watermark function Mark_text ($background, $text, $x, $y) {$back =imagecreatefromjpeg ($background); $color =imagecolorallocate ($back, 0, 255, 0); Imagettftext ($back, 0, $x, $y, $color, "Simkai.ttf", $text); Imagejpeg ($back, "./images/hee7.jpg"); Imagedestroy ($back); }
Finally, I wrote a small demo that mainly describes the dynamic parameters. Demo
Uploadify's usage and dynamic parameters provide demo download