1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- namespace App\Widget\Tools;
- use Illuminate\Support\Facades\Request;
- use Intervention\Image\Facades\Image;
- //use FFMpeg;
- /**
- * Created by PhpStorm.
- * User: steven
- * Date: 16/9/12
- * Time: 下午8:06
- */
- class VideoUpload
- {
- protected static function mkFolder($path)
- {
- if (!is_readable($path)) {
- mkdir($path, 0700, true);
- }
- }
- /*
- * 文件存储工具
- *
- */
- public static function mvFile($fileName, $sizex = 150, $sizey = 200,$isImage = false, $dir = 'order')//200 270
- {
- if (!Request::hasFile($fileName)) return false;
- $file = Request::file($fileName);
- VideoUpload::mkFolder(public_path('upload/'));
- if(Request::get('article_id'))$dir=Request::get('article_id');
- $filePath = public_path('upload/'.$dir.'/');
- VideoUpload::mkFolder($filePath);
- $fileName = time() . '.' . $file->getClientOriginalExtension();
- // $fileName = $clientName . '.' . $file->getClientOriginalExtension();
- \Log::info($filePath. $fileName);
- if($isImage){
- if (!Image::make($file)->resize($sizex, $sizey)->save($filePath. $fileName)) return false;
- }else{
- $file->move($filePath, $fileName);
- /* //正常缩略图
- $ffmpeg = FFMpeg\FFMpeg::create(array(
- 'ffmpeg.binaries' => '/usr/bin/ffmpeg',
- 'ffprobe.binaries' => '/usr/bin/ffprobe'
- ));
- $video = $ffmpeg->open($filePath. $fileName);
- $vpath = $filePath;
- if (!file_exists($vpath)) {
- if (!@mkdir($vpath, 0755, true)) {
- return ErrorCode::ATTACHMENT_MKDIR_FAILED;
- }
- }
- $pic = $vpath. $fileName.'.jpg';
- \Log::info($pic);
- $video
- ->frame(FFMpeg\Coordinate\TimeCode::fromSeconds(1))
- ->save( $pic );*/
- }
- return '/upload/' .$dir.'/'. $fileName;
- }
- }
|