Foreground HTML code:
<Divclass= "Control-group"ID= "Title-control-group"><labelclass= "Control-label"><?=_ (' About picture (*) ')?></label><Divclass= "Controls"> <Div><inputID= "About_file_upload"name= "About_file_upload"type= "File" /> <inputtype= "button"value= "OK upload"onclick= "javascript:$" (' #about_file_upload '). Uploadify (' upload ', ' * '); "> || <ahref= "Javascript:clearupload (' about ');"><?=_ (' Clear upload list ')?></a></Div> <Pstyle= "color:red;"><?php $msg =_ (' please upload in the following languages: '); for ($n =0; $n <count ($lang), $n + +) {$t. = $lang [$n] [' Lang ']. ', '; } $t =substr ($t, 0,strlen ($t)-1); echo $msg. $t; ?></P> <spanID= "About_filenames"></span> <inputtype= "hidden"name= "About_images"ID= "About_images"/> <inputtype= "hidden"name= "Temp_about_images"ID= "Temp_about_images"/></Div></Div></Div><Scriptsrc= "/theme/<?=t_d?>/assets/uploadify/jquery.uploadify.min.js"type= "Text/javascript" ></Script><Linkhref= "/theme/<?=t_d?>/assets/uploadify/uploadify.css"rel= "stylesheet"type= "Text/css" />
Front desk JS:
$ ("#about_file_upload"). uploadify ({' swf ': '/theme/<?=t_d?>/assets/uploadify/uploadify.swf ',//The required Flash files' cancelimg ': ' Cancel.png ',//a single canceled upload of a picture' Auto ':false, ' Uploader ': '/management/common/uploadify ',//Implementing the Upload program' Folder ': ' Uploads/pic ',//upload directory on the service side' Multi ':true,//do you want to upload more files ?' Displaydata ': ' Speed ',//How the progress bar is displayed' filetypeexts ': ' *.jpg;*.jpeg;*.gif;*.png ',//types of files that can be uploaded' Filesizelimit ': ' 2MB ',//Limit File Size' Simuploadlimit ': 3,//Uploading data concurrently' Queuesizelimit ': <?php echo Count ($lang);? ,//number of files that can be uploaded' ButtonText ': ' <?=_ (' File Upload ')?> ',//Replace text on a button with text' buttonimg ': ' Css/images/browsebtn.png ',//Replace the upload button' Width ': 80,//size of the buttonimg' Height ': 24,//' FormData ': {' source ': ' Doctor '}, Onswfready:function(){ $("#doctors_FileNames"). HTML ('); $("#temp_doctor_images"). Val ('); }, Onuploadsuccess:function(file, data, response) {varmsg=$ ("#about_FileNames"). html (); varimage_data=$ ("#temp_about_images"). Val (); Msg+=data+ "," + "<br/>"; Image_data+=data+ ","; $("#about_FileNames"). HTML (msg); $("#temp_about_images"). Val (Image_data); }, Onqueuecomplete:function() { varmsg=$ ("#about_FileNames"). html (); varimage_data=$ ("#temp_about_images"). Val (); $("#about_images"). Val (Image_data); } }); }); //Clear Upload functionclearupload (source) {if(source== ' Doctor ') { $(' #doctor_file_upload '). Uploadify (' Cancel ', ' * '); $("#doctors_FileNames"). HTML ('); $("#doctor_images"). Val ('); $("#temp_doctor_images"). Val ('); } Else if(source== ' About ') { $(' #about_file_upload '). Uploadify (' Cancel ', ' * '); $("#about_FileNames"). HTML ('); $("#about_images"). Val ('); $("#temp_about_images"). Val ('); } }
Back-end PHP code:
//File Upload functionuploadify () {$sub=$this->input->post (); if(!Empty($_files)) { $source=$sub[' Source ']; $year=Date("Y", Time()); $month=Date("N", Time()); $day=Date("J", Time()); $ext=End(Explode(‘.‘,$_files["Filedata"] ["Name"])); $_dir= "./uploads/$source/$year/$month/$day/"; if(!Is_dir($his _dir)) { $this->commfunctions->mkpath ($_dir); } Move_uploaded_file($_files["Filedata"] ["Tmp_name"],$_dir.MD5( Time()).‘ _‘.MD5($_files["Filedata"] ["Name"]). '. '.$ext); Echo"/uploads/$source/$year/$month/$day/".MD5( Time()).‘ _‘.MD5($_files["Filedata"] ["Name"]). '. '.$ext; } }
Realize:
Uploadify plugin for multi-file upload