Development requirements: App side upload video, while uploading video cover + video every 10 seconds to take frame picture (front-end operation, here only to deal with upload function), because the picture and video Save the path is different, there are size limits, etc., so the original file by TP slightly modified under. The code is as follows:
App uploads multiple pictures and videos public function appupvideopic ($m =1200, $s =300) {if (! $m) $m = 1200;//Large figure if (! $s) $s = 300;//
Small Figure $imagefile = array ();
$videofile = Array (); Group file classes (array subscript is not optimized, you can use the time to deal with) foreach ($_files as $ks => $vs) {//upload is picture if (Strpos $
vs[' type '], ' mage ') = = ' 1 ') {$imagefile [$ks] = $vs;
//uploaded is video if (Strpos ($vs [' type '], ' ideo ') = = ' 1 ') {$videofile [$ks] = $vs;
}} $data = Array ();
$errmsg = ' upload failed '; if ($imagefile) {$config = array (' RootPath ' => './uploads/images/', ' SAVEP
Ath ' => date (' Ymd '), ' maxSize ' => 21048576, ' savename ' => array (' uniqid ', '), ' Exts ' => array (' jpg ', ' gif ', ' PNG ', ' jpeg '), ' autosub ' => true, ' subn
Ame ' => ' a ',);$upload = new Upload ($config);
$info = $upload->upload ($imagefile);
Start uploading if ($info) {$imgname _m = ';
$imgname _s = ';
$framename _m = ';
$framename _s = ';
foreach ($info as $k => $v) {$savePath = $v [' Savepath '];
$saveName = $v [' Savename ']; $imgPath = $savePath.
$saveName;
$imgPath _m = $this->thumb ($m, $m, $imgPath);
$imgPath _s = $this->thumb ($s, $s, $imgPath); @unlink (C ("Upload_path"). ' Images/'.
$imgPath);//delete original//1 upload is cover, otherwise video frame screenshot set if (Strpos ($k, ' ramepic ') = = 1) { $framename _m. = $imgPath _m.
','; $framename _s. = $imgPath _s.
','; else {$imgname _m. = $imgPath _m.
','; $imgname_s. = $imgPath _s.
',';
} $data [' cover '] = Trim ($imgname _m, ', ');
$data [' covers '] = Trim ($imgname _s, ', ');
$data [' frame '] = Trim ($framename _m, ', ');
$data [' frames '] = Trim ($framename _s, ', ');
}else{$errmsg = $upload->geterror ();
} if ($videofile) {$config = array (' RootPath ' => './uploads/video/'), ' Savepath ' => date (' Ymd '), ' maxSize ' => 2145728000,//200m ' savename ' T Array (' uniqid ', '), ' exts ' => Array (' mp4 ', ' avi ', ' mov ', ' rmvb ', ' wmv '), ' autosub ' =>
True, ' subname ' => ' a ',);
$upload = new Upload ($config);//$infos = $upload->upload ($videofile); Start uploading if ($infos) {$infosa = $infos [' file '] [' Savepath ']]. $infos [' file '] [' savename '];
$data [' video '] = $infosa;
else{$errmsg = $upload->geterror ();
} if ($data) {return Array (' Code ' =>200, ' msg ' => ' upload succeeded ', ' data ' => $data,);
}else{return Array (' Code ' =>400, ' msg ' => $errmsg, ' data ' => '); }
}
Let's put the thumbnail on.
/* Generate Thumbnail method
@ H W need to crop the width of high
@ file based on the diagram to operate
@ SaveFile Customizable Save file name
@ type for crop type 1 = equal scale type 2 = after scaling fill Type 3 = center cropping type 4= in upper left corner cropping type 5 = lower right corner cropping type 6 = fixed size zoom
type
/Private function thumb ($h, $w, $file, $type =1, $savefile = ', $savestyle = 1) {
$abspath = C (' Upload_path '). ' Images/';
if (!file_exists ($abspath. $file)) {return
false;
} else{
$img = new Image ();
$img->open ($abspath. $file);
$info = PathInfo ($file);
if ($savefile = = ") {
$savefile = ';
$savefile. = (Isset ($info [' dirname ']) && $info [' dirname ']!= ')? $info [' dirname ']. ' /' : '';
if ($savestyle = = 1) {
$savefile. = $info [' filename ']. ' _ '. $h. ' _ '. $w. '. $info [' extension '];
} ElseIf ($savestyle = = 2) {
$savefile. = $info [' filename ']. $w. '. $info [' extension '];
}
else {
$savefile = $savefile. '. $info [' extension '];
}
$img->thumb ($h, $w, $type)->save ($abspath. $savefile);
return $savefile;
}
It's a rough writing, it's a thought. You can leave a message.