示例#1
0
 public static function upload($file, $path, $width = 110, $makeThumb = true, $fileName = '')
 {
     if (!File::exists($path)) {
         File::makeDirectory($path, 493, true);
     }
     if (!empty($fileName)) {
         $fileName .= '.' . $file->getClientOriginalExtension();
     } else {
         $fileName = Str::slug(str_replace('.' . $file->getClientOriginalExtension(), '', $file->getClientOriginalName())) . '.' . date('d-m-y') . '.' . $file->getClientOriginalExtension();
     }
     $path = str_replace(['\\', '/'], DS, $path);
     if ($file->move($path, $fileName)) {
         BackgroundProcess::resize($width, $path, $fileName);
         if ($makeThumb) {
             BackgroundProcess::makeThumb($path, $fileName);
         }
         return $path . DS . $fileName;
     }
     return false;
 }