public function uploadImage($imageFile, $field = null)
    {
        $this->uploadFieldName = $this->getUploadFieldName($field);
        $this->uploadFieldOptions = $this->getUploadFieldOptions($this->uploadFieldName);

        // validate it
        $this->validateImage($imageFile, $this->uploadFieldName, $this->uploadFieldOptions);

        // handle upload
        $filePath = $this->hasFileField($this->uploadFieldName)
            ? $this->handleFileUpload($imageFile)
            : $this->handleImageUpload($imageFile);

        // hold old file
        $currentFile = $this->getOriginal($this->uploadFieldName);

        // update the model with field name
        $this->updateModel($filePath, $this->uploadFieldName);

        // delete old file
        if ($currentFile != $filePath) {
            $this->deleteImage($currentFile);
        }
    }
public function uploadImage($imageFile, $field = null)
    {
        $this->uploadFieldName = $this->getUploadFieldName($field);
        $this->uploadFieldOptions = $this->getUploadFieldOptions($this->uploadFieldName);

        // validate it
        $this->validateImage($imageFile, $this->uploadFieldName, $this->uploadFieldOptions);

        // handle upload
        $filePath = $this->hasFileField($this->uploadFieldName)
            ? $this->handleFileUpload($imageFile)
            : $this->handleImageUpload($imageFile);

        // hold old file
        $currentFile = $this->getOriginal($this->uploadFieldName);

        // update the model with field name
        $this->updateModel($filePath, $this->uploadFieldName);

        // delete old file
        if ($currentFile != $filePath) {
            $this->deleteImage($currentFile);
        }
    }
public function uploadImage ( $ imageFile , $ field = null ) { $ this -> uploadFieldName = $ this -> getUploadFieldName ( $ field ) ; $ this -> uploadFieldOptions = $ this -> getUploadFieldOptions ( $ this -> uploadFieldName ) ; // validate it $ this -> validateImage ( $ imageFile , $ this -> uploadFieldName , $ this -> uploadFieldOptions ) ; // handle upload $ filePath = $ this -> hasFileField ( $ this -> uploadFieldName ) ? $ this -> handleFileUpload ( $ imageFile ) : $ this -> handleImageUpload ( $ imageFile ) ; // hold old file $ currentFile = $ this -> getOriginal ( $ this -> uploadFieldName ) ; // update the model with field name $ this -> updateModel ( $ filePath , $ this -> uploadFieldName ) ; // delete old file if ( $ currentFile != $ filePath ) { $ this -> deleteImage ( $ currentFile ) ; } }
Upload and resize image

@param $imageFile
@param null $field
@throws InvalidUploadFieldException|\Exception
Upload and resize image