コード例 #1
0
 public function save_upload(UploadedFile $file_upload, $extension)
 {
     $uploads_dir = Config::get('dirs.uploads');
     $filename = pathinfo($file_upload->getClientOriginalName(), PATHINFO_FILENAME);
     $target_name = $uploads_dir . strftime('/%Y/%m%d/') . $filename . '.' . $extension;
     $n = 1;
     while (File::exists(base_path($target_name))) {
         $target_name = $uploads_dir . strftime('/%Y/%m%d/') . $filename . '(' . $n . ').' . $extension;
         $n++;
     }
     Utils::file_force_contents(base_path($target_name), File::get($file_upload));
     //Utils::gzCompressFile(base_path($target_name));
     return $target_name;
 }
コード例 #2
0
 public function save_picture($user_name, UploadedFile $file_upload)
 {
     $tmp_name = storage_path('tmp/') . str_random(16) . '.' . $file_upload->getClientOriginalExtension();
     Utils::file_force_contents($tmp_name, File::get($file_upload));
     $pictures_dir = Config::get('dirs.pìctures', '/uploads/pictures');
     $target_name = $pictures_dir . '/' . $user_name . '.jpeg';
     if (!File::isDirectory(base_path() . $pictures_dir)) {
         mkdir(base_path() . $pictures_dir, 0770, true);
     }
     $n = 1;
     while (File::exists(base_path() . $target_name)) {
         $target_name = $pictures_dir . '/' . $user_name . '(' . $n . ').jpeg';
         $n++;
     }
     Imaging::img_resize($tmp_name, base_path() . $target_name, 200, 300);
     File::delete($tmp_name);
     return $target_name;
 }