예제 #1
2
 public function upload(UploadedFile $picture)
 {
     $original = pathinfo($picture->getClientOriginalName(), PATHINFO_FILENAME);
     $sanitize = preg_replace('/[^a-zA-Z0-9]+/', '-', $original);
     $fileName = $sanitize . '.' . $picture->getClientOriginalExtension();
     $destination = public_path() . DIRECTORY_SEPARATOR . 'uploads/courses';
     $uploaded = $picture->move($destination, $fileName);
     Image::make($uploaded)->fit(300, 300)->save($destination . '/300x300-' . $fileName);
     return $fileName;
 }
예제 #2
0
 /**
  * @param \Illuminate\Http\UploadedFile $file
  */
 public function handleImageUpload($file)
 {
     // $file = $request->file('image'); or
     // $fileName = 'somename';
     $destinationPath = public_path('uploads/mage2/themes');
     $fileName = $file->getClientOriginalName();
     $file->move($destinationPath, $fileName);
     return $destinationPath . DIRECTORY_SEPARATOR . $fileName;
 }
예제 #3
0
 public function upload(UploadedFile $file)
 {
     $original = Auth::user()->fullname . '-' . pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
     $sanitize = preg_replace('/[^a-zA-Z0-9]+/', '-', $original);
     $fileName = $sanitize . '.' . $file->getClientOriginalExtension();
     $destination = public_path() . DIRECTORY_SEPARATOR . 'uploads/assignments';
     $uploaded = $file->move($destination, $fileName);
     return $fileName;
 }
예제 #4
0
 public function saveImage(UploadedFile $image, $cover = false)
 {
     $fileName = Uuid::uuid1() . '.' . $image->getClientOriginalExtension();
     $destination = public_path() . DIRECTORY_SEPARATOR . 'uploads';
     $uploaded = $image->move($destination, $fileName);
     if ($cover) {
         Image::make($uploaded)->fit(253, 190)->save($destination . '/253x190-' . $fileName);
     } else {
         Image::make($uploaded)->fit(45, 45)->save($destination . '/45x45-' . $fileName);
         Image::make($uploaded)->fit(120, 120)->save($destination . '/120x120-' . $fileName);
     }
     return $fileName;
 }