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