Ejemplo n.º 1
0
 public static function commonUploadImage($input, $path, $type = null)
 {
     $data = null;
     $sessionId = Common::checkSessionLogin($input);
     if (isset($input['image_url'])) {
         foreach ($input['image_url'] as $key => $value) {
             $filename[$key] = $value->getClientOriginalName();
             $filename[$key] = changeFileNameImage($filename[$key]);
             $filename[$key] = $key . $filename[$key];
             $pathUpload = public_path() . $path . '/' . $input['user_id'];
             $uploadSuccess = $value->move($pathUpload, $filename[$key]);
             if ($key == 0) {
                 if ($type == 1) {
                     $image = Image::make(sprintf('' . $pathUpload . '/%s', $filename[$key]))->save();
                 } else {
                     $image = Image::make(sprintf('' . $pathUpload . '/%s', $filename[$key]))->resize(USER_AVATAR_WIDTH, USER_AVATAR_HEIGHT)->save();
                 }
             } else {
                 $image = Image::make(sprintf('' . $pathUpload . '/%s', $filename[$key]))->save();
             }
             $data[$key] = ['image_url' => $filename[$key]];
         }
         return Common::returnData(200, SUCCESS, $input['user_id'], $sessionId, $data);
     }
     throw new Prototype\Exceptions\UploadErrorException();
 }
Ejemplo n.º 2
0
 public static function uploadImg($path, $folder, $imageUrl, $imageCurrent = NULL)
 {
     $destinationPath = public_path() . '/' . $path . '/' . $folder . '/';
     if (Input::hasFile($imageUrl)) {
         $file = Input::file($imageUrl);
         $filename = $file->getClientOriginalName();
         $filename = changeFileNameImage($filename);
         $uploadSuccess = $file->move($destinationPath, $filename);
         return $filename;
     }
     if ($imageCurrent) {
         return $imageCurrent;
     }
 }