php+ Seven Cow cloud storage upload Image code snippet

Source: Internet
Author: User

November 14, 2014 16:37:51

The first piece of code is to upload a single image, the second is to upload multiple images

1 //uploaded to seven kn2 //Single file3 //FormName: The name of the form; Pre: The name of the image shown in the image URL (that is, key in the seven bull)4      Public functionUpimage ($formname,$pre)5     {6         if(Empty($_files[$formname[' Size '])) {7             return Array(8' Qiniu_name ' = ' 000 ',9' file_name ' = ' 0000 'Ten                 ); One         } A  -         //get suffix -         $realname=$_files[$formname[' Name ']; the         $arrRealName=Explode(‘.‘,$realname); -         $file _name=$arrRealName[0]; -         $stuffix=End($arrRealName); -  +         //Organization Full library file name -         $rand _time=$this-getmsec (); +         $qiniu _name= ' Qiniu '.$rand _time.‘ _‘.$pre.‘.‘.$stuffix; A         $filepath=$_files[$formname[' Tmp_name ']; at  -         //Upload -         $this->ci->load->library (' Qiniu '); -         $this->ci->qiniu->upfile ($qiniu _name,$filepath); -         //$imgbaseurl = $this->ci->qiniu->getimagebaseurl ($filename); - //return $imgbaseurl; in           -         return Array( to' Qiniu_name ' =$qiniu _name, +' file_name ' =$file _name -             ); the     } *  $      Public functionUpmoreimage ($formname,$pre)Panax Notoginseng     { -         if(Empty($_files[$formname])) { the             return‘‘; +         } A  the         $count=Count($_files[$formname[' Name ']); +  -         $arrImages=Array(); $         foreach($_files[$formname[' Name '] as $k=$name) { $             if($_files[$formname[' Size '] [$k]) { -                 $arrImages[$k[' name '] =$name; -                 $arrImages[$k[' type '] =$_files[$formname[' type '] [$k]; the                 $arrImages[$k[' tmp_name '] =$_files[$formname[' Tmp_name '] [$k]; -                 $arrImages[$k[' ERROR '] =$_files[$formname[' Error '] [$k];Wuyi                 $arrImages[$k[' size '] =$_files[$formname[' Size '] [$k]; the             } -         } Wu  -         $this->ci->load->library (' Qiniu '); About         $arrUpInfo=Array(); $         foreach($arrImages  as $k=$v) { -             //get suffix -             $realname=$v[' Name ']; -             $arrRealName=Explode(‘.‘,$realname); A             $file _name=$arrRealName[0]; +             $stuffix=End($arrRealName); the  -             //Organization Full library file name $             $rand _time=$this-getmsec (); the             $qiniu _name= ' Qiniu '.$rand _time.‘ _‘.$pre.‘.‘.$stuffix; the             $filepath=$v[' Tmp_name ']; the  the             //Upload -             $this->ci->qiniu->upfile ($qiniu _name,$filepath); in  the             $arrUpInfo[$k] =Array( the' Qiniu_name ' =$qiniu _name, About' file_name ' =$file _name the                 ); the         } the  +         return $arrUpInfo; -  the}

php+ Seven Cow cloud storage upload Image code snippet

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.