Upload a new photo to the album
@return \Illuminate\Http\JsonResponse
514858
public function upload()
    {
        // upload the photo here
        $attributes = request()->validate(Document::$rules);

        // get the documentable
        $documentable = input('documentable_type')::find(input('documentable_id'));

        if (!$documentable) {
            return json_response_error('Whoops', 'We could not find the documentable.');
        }

        // move and create the photo
        $photo = $this->moveAndCreateDocument($attributes['file'], $documentable);

        if (!$photo) {
            return json_response_error('Whoops', 'Something went wrong, please try again.');
        }

        return json_response(['id' => $photo->id]);
    }
371355
public function upload()
	{
		$response = array('uploaded' => false);

		foreach ((array)$_FILES as $file) {
			$targetFolder = isset($_POST['folder']) ? $_POST['folder'] : '/';
			$response = array_merge($response, $this->uploadFile($file, $targetFolder . '/'));
		}
        $this->returnJson($response);
	}
382262
public function uploadImage()
    {
        $image = $this->getTempImage();
        $file = $_FILES['Filedata'];
        $uploadError = Nip_File_System::instance()->getUploadError($file, $image->extensions);

        if (!$uploadError) {
            $image->setResourceFromUpload($file);
            if ($image->validate()) {
                $image->resize();
                $image->save();

                $imageCrop = $this->getTempImage();
                $imageCrop->copyResource($image);

                $ratio = $imageCrop->getRatio();
                $max_width = $imageCrop->minWidth > 600 ? $imageCrop->minWidth : 600;
                $heightCalculated = round($max_width / $ratio);
                if ($heightCalculated < $imageCrop->minHeight) {
                    $max_width = round($imageCrop->minHeight * $ratio);
                }

                $imageCrop->max_width = $max_width;
                $imageCrop->setName('crop-' . $image->name);
                $imageCrop->resize();
                $imageCrop->save();

                return $imageCrop;
            } else {
                $this->errors['upload'] = 'Eroare dimensiuni.';
            }
        } else {
            $this->errors['upload'] = $uploadError;
        }


        return false;
    }
206155
public T photos_upload(File photo)
    throws FacebookException, IOException {
    return photos_upload(photo, /*caption*/ null, /*albumId*/ null) ;
  }
981835
public function image() {
		if (Request::hasFile('image') && Request::has('table_name') && Request::has('field_name')) {
			return json_encode(self::saveImage(
				Request::input('table_name'), 
				Request::input('field_name'), 
				Request::file('image'),
				null,
				Request::file('image')->getClientOriginalExtension()
			));
		} elseif (!Request::hasFile('image')) {
			return 'no image';
		} elseif (!Request::hasFile('table_name')) {
			return 'no table_name';
		} elseif (!Request::hasFile('field_name')) {
			return 'no field_name';
		}
	}
714945
protected function actionUpload()
    {
        switch (htmlspecialchars($_GET['action'])) {
            case 'uploadimage':
                $this->driver->uploadDir .= DIRECTORY_SEPARATOR . 'image';
                $this->driver->maxFileSize = $this->config['imageMaxSize'];
                $this->driver->accept = $this->reAccept($this->config['imageAllowFiles']);
                $this->driver->fileName = $this->config['imageFieldName'];
                break;
            case 'uploadvideo':
                $this->driver->uploadDir .= DIRECTORY_SEPARATOR . 'video';
                $this->driver->maxFileSize = $this->config['videoMaxSize'];
                $this->driver->accept = $this->reAccept($this->config['videoAllowFiles']);
                $this->driver->fileName = $this->config['videoFieldName'];
                break;
            default:
                $this->driver->uploadDir .= DIRECTORY_SEPARATOR . 'file';
                $this->driver->maxFileSize = $this->config['fileMaxSize'];
                $this->driver->accept = $this->reAccept($this->config['fileAllowFiles']);
                $this->driver->fileName = $this->config['fileFieldName'];
        }
        $rst = $this->driver->chunkUpload();
        return $this->response($rst);
    }
837340
public function upload()
    {
        $params = $this->getUploadParams();

        if ($params) {
            $class = $this->class;
            $uri = $class::getUri();
            $document = static::post($this->client, $uri, $params);

            /** @var Model $instance */
            $instance = new $this->class($this->client, $document);
            $instance->exists = true;
            $instance->cacheFields($document);
            return $instance;
        }

        return null;
    }
17847
function addPhoto($photo) {
        if (!file_exists($photo['tmp_name']) || !is_uploaded_file($photo['tmp_name'])) {
            $o = array('state' => false); 
        } else {
            
            $photos = new Zend_Gdata_Photos($this->client);
            
            $fd = $photos->newMediaFileSource($photo["tmp_name"]);
            $fd->setContentType($photo["type"]);
            
            $entry = new Zend_Gdata_Photos_PhotoEntry();
            $entry->setMediaSource($fd);
            $entry->setTitle($photos->newTitle($photo["name"]));
            
            $albumQuery = new Zend_Gdata_Photos_AlbumQuery;
            $albumQuery->setUser($this->user);
            $albumQuery->setAlbumId($this->album);
            
            $albumEntry = $photos->getAlbumEntry($albumQuery);
            
            $result = $photos->insertPhotoEntry($entry, $albumEntry);
            if ($result) {
                $o = array('state' => true, 'id' => $result->getGphotoId());                 
            } else {
                $o = array('state' => false); 
            }            
        }
        return $o;
    }
744837
def admin_add_photo
      return if !user_is_allowed('media', 'edit')      
            
      x = Media.maximum(:media_order, :conditions => {:mls => params[:mls], :media_type => 'Photo'})
      x = 0 if x.nil?
      
      m = Media.new
      m.id            = Media.maximum(:id) + 1
      m.mls 		  = params[:mls]
      m.date_modified = DateTime.now                  
      m.media_order   = x + 1
      m.media_type 		= 'Photo'
      m.image         = params[:image]
      m.save
      
      render :text => "<script type='text/javascript'>parent.controller.after_image_upload();</script>"                        
    end
177001
public function postImage()
	{
		$file = Input::file('file');
		$imageDir = Config::get('core::wardrobe.image_dir');
		$destinationPath = public_path(). "/{$imageDir}/";
		$filename = $file->getClientOriginalName();
		$resizeEnabled = Config::get('core::wardrobe.image_resize.enabled');
		
		if ($resizeEnabled)
		{
			$resizeWidth = Config::get('core::wardrobe.image_resize.width');
			$resizeHeight = Config::get('core::wardrobe.image_resize.height');
			$image = Image::make($file->getRealPath())->resize($resizeWidth, $resizeHeight, true);
			$image->save($destinationPath.$filename);
		}
		else
		{
			$file->move($destinationPath, $filename);
		}

		if (File::exists($destinationPath.$filename))
		{
			// @note - Using the absolute url so it loads images when ran in sub folder
			// this will make exporting less portable and may need to re-address at a later point.
			return Response::json(array('filename' => url("/{$imageDir}/".$filename)));
		}
		return Response::json(array('error' => 'Upload failed. Please ensure your public/img directory is writable.'));
	}
346950
private function getImages()
    {
        $photos = $this->event->get('photo');
        $largetstPhoto = array_pop($photos);
        $response = $this->http->get($this->buildApiUrl('getFile'), [
            'file_id' => $largetstPhoto['file_id'],
        ]);

        $responseData = json_decode($response->getContent());

        if ($response->getStatusCode() !== 200) {
            throw new TelegramAttachmentException('Error retrieving file url: '.$responseData->description);
        }

        $url = $this->buildFileApiUrl($responseData->result->file_path);

        return [new Image($url, $largetstPhoto)];
    }
1047349
public function upload(Request $request)
    {
        $json = [];
        foreach ($request->file('file') as $file) {
            $this->storage->putFile($request->get('directory'), $file);
        }

        $json['success'] = trans('admin::image.success.upload');

        return response()
            ->json($json);
    }
1358016
public function actionImages(): Response
    {
        $result = [];

        foreach (AttachmentModel::find()->each() as $attachment) {
            $result[] = [
                'id' => $attachment->id,
                'url' => $attachment->getFileUrl('origin'),
                'thumb' => $attachment->getFileUrl('thumbnail'),
            ];
        }

        return $this->asJson($result);
    }
84487
public function actionDeleteImage(): Response
    {
        $model = $this->findModel($this->attachmentModelClass, Yii::$app->request->post('id'));

        $model->delete();

        return $this->asJson([
            'status' => 'success',
        ]);
    }
1109828
public function uploadPhoto()
    {
        $result = [];
        if ($this->validate()) {
            $fileOrgname = Helper::validateFilename($this->file->name, 40);
            $filename = $fileOrgname;
            $filePath = Media::getCurrentDirectory() . DIRECTORY_SEPARATOR . $filename;
            $result['originName'] = $this->file->name;
            if ($this->file->saveAs($filePath)) {
                $result['originPath'] = $filePath;
                if ($this->options->resize) {
                    $tsize = (new Size(getimagesize($filePath)))->resize($this->options->resizeTo);
                    $size    = new \Imagine\Image\Box($tsize->width, $tsize->height);
                    $imagine = new \Imagine\Gd\Imagine();
                    $resizedName = 'primary_' . $filename;
                    $resizedPath = Media::getCurrentDirectory() . DIRECTORY_SEPARATOR . $resizedName;
                    $imagine->open($filePath)->resize($size)->save($resizedPath);
                    $filename = $resizedName;
                    $filePath = $resizedPath;
                }
                $result['success'] =  true;
                $result['fileName'] = $filename;
                $result['filePath'] = $filePath;
                $result['size'] = filesize($filePath);
                if ($this->options->generateThumbnail) {
                    $thumbName = 'thumb_' . $fileOrgname;
                    $thumbPath = Media::getCurrentDirectory() . DIRECTORY_SEPARATOR . $thumbName;
                    $tsize = (new Size(getimagesize($filePath)))->resize($this->options->thumbnailSize);
                    $size    = new \Imagine\Image\Box($tsize->width, $tsize->height);
                    $imagine = new \Imagine\Gd\Imagine();
                    try {
                        $imagine->open($filePath)->thumbnail($size)->save($thumbPath);
                        $result['thumbnailPath'] = $thumbPath;
                        $result['thumbnailName'] = $thumbName;

                    } catch (\Exception $e) {
                        //Nothing to do
                        \Yii::$app->log->logger->log($e);
                    }
                }
            }

        }
        $result['error'] = new ModelErrors($this->getErrors());
        return new UploadResult($result);
    }
1166430
public function changePicture()
    {
        $id = $this->Auth->user('id');

        if ($this->request->getData('file')) {
            //Deletes any picture that already exists
            foreach (((new Folder(USER_PICTURES))->find($id . '\..+')) as $filename) {
                @unlink(USER_PICTURES . $filename);
            }

            $filename = sprintf('%s.%s', $id, pathinfo($this->request->getData('file')['tmp_name'], PATHINFO_EXTENSION));

            $uploaded = $this->Uploader->set($this->request->getData('file'))
                ->mimetype('image')
                ->save(USER_PICTURES, $filename);

            if (!$uploaded) {
                return $this->setUploadError($this->Uploader->getError());
            }

            //Updates the authentication data and clears similar thumbnails
            $this->Auth->setUser(array_merge($this->Auth->user(), ['picture' => $uploaded]));
            (new ThumbManager)->clear($uploaded);
        }
    }
554034
public function upload()
    {
        $filename = $this->getName(true);

        if ( ! is_readable($filename) ) {
            throw new FileExistException('Image file from disk is not readable');
        }

        try {
            $this->getSoapClient()->UploadImage(array(
                'image'    => base64_encode(file_get_contents($filename)) ,
                'filename' => basename($filename) ,
            ));

            return $this;
        } catch ( SoapException $e ) {
            throw new UploadException('Error while uploading the image' , $e);
        }
    }