public function upload($file, $dir = null, $createDimensions = false, $autonumber = true)
    {
        if ($file) {
            // Generate random dir
            if (! $dir) {
                $dir = str_random(8);
            }
     
            // Get file info and try to move
            $destination = Config::get('redminportal::image.upload_path') . $dir;
            
            if ($autonumber) {
                $filename = $this->autoNumberFile($destination, $file);
            } else {
                $filename = $file->getClientOriginalName();
            }
            
            $path        = RHelper::joinPaths(Config::get('redminportal::image.upload_dir'), $dir, $filename);
            $uploaded    = $file->move($destination, $filename);
     
            if ($uploaded) {
                if ($createDimensions) {
                    $this->createDimensions($path);
                }
     
                return $path;
            }
        }
    }
public function upload($file, $dir = null, $createDimensions = false, $autonumber = true)
    {
        if ($file) {
            // Generate random dir
            if (! $dir) {
                $dir = str_random(8);
            }
     
            // Get file info and try to move
            $destination = Config::get('redminportal::image.upload_path') . $dir;
            
            if ($autonumber) {
                $filename = $this->autoNumberFile($destination, $file);
            } else {
                $filename = $file->getClientOriginalName();
            }
            
            $path        = RHelper::joinPaths(Config::get('redminportal::image.upload_dir'), $dir, $filename);
            $uploaded    = $file->move($destination, $filename);
     
            if ($uploaded) {
                if ($createDimensions) {
                    $this->createDimensions($path);
                }
     
                return $path;
            }
        }
    }
public function upload ( $ file , $ dir = null , $ createDimensions = false , $ autonumber = true ) { if ( $ file ) { // Generate random dir if ( ! $ dir ) { $ dir = str_random ( 8 ) ; } // Get file info and try to move $ destination = Config :: get ( 'redminportal::image.upload_path' ) . $ dir ; if ( $ autonumber ) { $ filename = $ this -> autoNumberFile ( $ destination , $ file ) ; } else { $ filename = $ file -> getClientOriginalName ( ) ; } $ path = RHelper :: joinPaths ( Config :: get ( 'redminportal::image.upload_dir' ) , $ dir , $ filename ) ; $ uploaded = $ file -> move ( $ destination , $ filename ) ; if ( $ uploaded ) { if ( $ createDimensions ) { $ this -> createDimensions ( $ path ) ; } return $ path ; } } }
Upload an image to the public storage
@param  File $file
@param string Directory (optional, defaults to null)
@param bool Whether to create all dimensions (optional, defaults to false)
@param bool Automatically appends number if file already exists (optional, defaults to true)
@return string
Upload an image to the public storage