src/GuillermoMartinez/Filemanager/Filemanager.php
public function upload($file,$path){
        if( $this->validExt($file->getClientOriginalName())){
            if($file->getClientSize() > ($this->getMaxUploadFileSize() * 1024 * 1024) ){

                $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_SERVER","params"=>array($file->getClientSize()));
                $this->setInfo(array("msg"=>$result));

                if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido server: ".$file->getClientSize());
                return ;
            }elseif($file->getClientSize() > ($this->config['upload']['size_max'] * 1024 * 1024) ){

                $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_PERMITIDO","params"=>array($file->getClientSize()));
                $this->setInfo(array("msg"=>$result));

                if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido: ".$file->getClientSize());
                return ;
            }else{
                if($file->isValid()){
                    $dir = $this->getFullPath().$path;
                    $namefile = $file->getClientOriginalName();
                    $namefile = $this->clearNameFile($namefile);
                    $nametemp = $namefile;
                    if( $this->config["upload"]["overwrite"] ==false){
                        $ext = $this->getExtension($namefile);
                        $i=0;
                        while(true){
                            $pathnametemp = $dir.$nametemp;
                            if(file_exists($pathnametemp)){
                                $i++;
                                $nametemp = $this->removeExtension( $namefile ) . '_' . $i . '.' . $ext ;
                            }else{
                                break;
                            }
                        }
                    }
                    $file->move($dir,$nametemp);
                    $file = new  \SplFileInfo($dir.$nametemp);
                    return $file;
                }
            }
        }else{
            if( $this->config['debug'] ) $this->_log(__METHOD__." - file extension no permitido: ".$file->getExtension());
        }
    }
public function upload($file,$path){
        if( $this->validExt($file->getClientOriginalName())){
            if($file->getClientSize() > ($this->getMaxUploadFileSize() * 1024 * 1024) ){

                $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_SERVER","params"=>array($file->getClientSize()));
                $this->setInfo(array("msg"=>$result));

                if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido server: ".$file->getClientSize());
                return ;
            }elseif($file->getClientSize() > ($this->config['upload']['size_max'] * 1024 * 1024) ){

                $result = array("query"=>"BE_UPLOAD_FILE_SIZE_NOT_PERMITIDO","params"=>array($file->getClientSize()));
                $this->setInfo(array("msg"=>$result));

                if( $this->config['debug'] ) $this->_log(__METHOD__." - file size no permitido: ".$file->getClientSize());
                return ;
            }else{
                if($file->isValid()){
                    $dir = $this->getFullPath().$path;
                    $namefile = $file->getClientOriginalName();
                    $namefile = $this->clearNameFile($namefile);
                    $nametemp = $namefile;
                    if( $this->config["upload"]["overwrite"] ==false){
                        $ext = $this->getExtension($namefile);
                        $i=0;
                        while(true){
                            $pathnametemp = $dir.$nametemp;
                            if(file_exists($pathnametemp)){
                                $i++;
                                $nametemp = $this->removeExtension( $namefile ) . '_' . $i . '.' . $ext ;
                            }else{
                                break;
                            }
                        }
                    }
                    $file->move($dir,$nametemp);
                    $file = new  \SplFileInfo($dir.$nametemp);
                    return $file;
                }
            }
        }else{
            if( $this->config['debug'] ) $this->_log(__METHOD__." - file extension no permitido: ".$file->getExtension());
        }
    }
public function upload ( $ file , $ path ) { if ( $ this -> validExt ( $ file -> getClientOriginalName ( ) ) ) { if ( $ file -> getClientSize ( ) > ( $ this -> getMaxUploadFileSize ( ) * 1024 * 1024 ) ) { $ result = array ( "query" => "BE_UPLOAD_FILE_SIZE_NOT_SERVER" , "params" => array ( $ file -> getClientSize ( ) ) ) ; $ this -> setInfo ( array ( "msg" => $ result ) ) ; if ( $ this -> config [ 'debug' ] ) $ this -> _log ( __METHOD__ . " - file size no permitido server: " . $ file -> getClientSize ( ) ) ; return ; } elseif ( $ file -> getClientSize ( ) > ( $ this -> config [ 'upload' ] [ 'size_max' ] * 1024 * 1024 ) ) { $ result = array ( "query" => "BE_UPLOAD_FILE_SIZE_NOT_PERMITIDO" , "params" => array ( $ file -> getClientSize ( ) ) ) ; $ this -> setInfo ( array ( "msg" => $ result ) ) ; if ( $ this -> config [ 'debug' ] ) $ this -> _log ( __METHOD__ . " - file size no permitido: " . $ file -> getClientSize ( ) ) ; return ; } else { if ( $ file -> isValid ( ) ) { $ dir = $ this -> getFullPath ( ) . $ path ; $ namefile = $ file -> getClientOriginalName ( ) ; $ namefile = $ this -> clearNameFile ( $ namefile ) ; $ nametemp = $ namefile ; if ( $ this -> config [ "upload" ] [ "overwrite" ] == false ) { $ ext = $ this -> getExtension ( $ namefile ) ; $ i = 0 ; while ( true ) { $ pathnametemp = $ dir . $ nametemp ; if ( file_exists ( $ pathnametemp ) ) { $ i ++ ; $ nametemp = $ this -> removeExtension ( $ namefile ) . '_' . $ i . '.' . $ ext ; } else { break ; } } } $ file -> move ( $ dir , $ nametemp ) ; $ file = new \ SplFileInfo ( $ dir . $ nametemp ) ; return $ file ; } } } else { if ( $ this -> config [ 'debug' ] ) $ this -> _log ( __METHOD__ . " - file extension no permitido: " . $ file -> getExtension ( ) ) ; } }
Mueve un arcivo subido
@param UploadedFile $file
@param string $path
@return SplFileInfo|null
Mueve un arcivo subido