public function handleUpload(&$uploader)
    {
        // store uploader
        $this->uploader =& $uploader;
        //store input
        $this->setInput();
        // tell uploader which field is uploaded
        $this->uploader->setField($this->field);
        // make temporary file
        $this->uploader->setDestination(sys_get_temp_dir());
        // loop validation rules
        foreach($this->validations as $validation) {
            $options = isset($validation['options']) ? $validation['options'] : null;
            $message = isset($validation['message']) ? $validation['message'] : null;
            // set rule
            $this->uploader->addValidationRule($validation['type'], $options, $message);
        }
        // upload
        if(!$this->uploader->process()) {
            // failure
            return false;
        }
        // loop field outputs
        $temporaryFile = sprintf('%s/%s', sys_get_temp_dir(), $this->uploader->getUploadedFileInfo()['name']);
        foreach($this->outputs as $outputName => $output) {
            $outputPath = $output->getDestination() .  $this->uploader->getUploadedFileInfo()['name'];
            if(is_file($outputPath)){
                $outputPath = sprintf('%s%s_%s', $output->getDestination(), time(),  $this->uploader->getUploadedFileInfo()['name']);
            }
            copy($temporaryFile, $outputPath);
            $this->outputsFiles[$outputName] = [
                'name' => $this->uploader->getUploadedFileInfo()['name'],
                'path' => $outputPath
            ];
        }
        // delete temporary file
        unlink($temporaryFile);
        // close upload
        $this->uploader->close();
        return true;
    }
public function handleUpload(&$uploader)
    {
        // store uploader
        $this->uploader =& $uploader;
        //store input
        $this->setInput();
        // tell uploader which field is uploaded
        $this->uploader->setField($this->field);
        // make temporary file
        $this->uploader->setDestination(sys_get_temp_dir());
        // loop validation rules
        foreach($this->validations as $validation) {
            $options = isset($validation['options']) ? $validation['options'] : null;
            $message = isset($validation['message']) ? $validation['message'] : null;
            // set rule
            $this->uploader->addValidationRule($validation['type'], $options, $message);
        }
        // upload
        if(!$this->uploader->process()) {
            // failure
            return false;
        }
        // loop field outputs
        $temporaryFile = sprintf('%s/%s', sys_get_temp_dir(), $this->uploader->getUploadedFileInfo()['name']);
        foreach($this->outputs as $outputName => $output) {
            $outputPath = $output->getDestination() .  $this->uploader->getUploadedFileInfo()['name'];
            if(is_file($outputPath)){
                $outputPath = sprintf('%s%s_%s', $output->getDestination(), time(),  $this->uploader->getUploadedFileInfo()['name']);
            }
            copy($temporaryFile, $outputPath);
            $this->outputsFiles[$outputName] = [
                'name' => $this->uploader->getUploadedFileInfo()['name'],
                'path' => $outputPath
            ];
        }
        // delete temporary file
        unlink($temporaryFile);
        // close upload
        $this->uploader->close();
        return true;
    }
public function handleUpload ( & $ uploader ) { // store uploader $ this -> uploader = & $ uploader ; //store input $ this -> setInput ( ) ; // tell uploader which field is uploaded $ this -> uploader -> setField ( $ this -> field ) ; // make temporary file $ this -> uploader -> setDestination ( sys_get_temp_dir ( ) ) ; // loop validation rules foreach ( $ this -> validations as $ validation ) { $ options = isset ( $ validation [ 'options' ] ) ? $ validation [ 'options' ] : null ; $ message = isset ( $ validation [ 'message' ] ) ? $ validation [ 'message' ] : null ; // set rule $ this -> uploader -> addValidationRule ( $ validation [ 'type' ] , $ options , $ message ) ; } // upload if ( ! $ this -> uploader -> process ( ) ) { // failure return false ; } // loop field outputs $ temporaryFile = sprintf ( '%s/%s' , sys_get_temp_dir ( ) , $ this -> uploader -> getUploadedFileInfo ( ) [ 'name' ] ) ; foreach ( $ this -> outputs as $ outputName => $ output ) { $ outputPath = $ output -> getDestination ( ) . $ this -> uploader -> getUploadedFileInfo ( ) [ 'name' ] ; if ( is_file ( $ outputPath ) ) { $ outputPath = sprintf ( '%s%s_%s' , $ output -> getDestination ( ) , time ( ) , $ this -> uploader -> getUploadedFileInfo ( ) [ 'name' ] ) ; } copy ( $ temporaryFile , $ outputPath ) ; $ this -> outputsFiles [ $ outputName ] = [ 'name' => $ this -> uploader -> getUploadedFileInfo ( ) [ 'name' ] , 'path' => $ outputPath ] ; } // delete temporary file unlink ( $ temporaryFile ) ; // close upload $ this -> uploader -> close ( ) ; return true ; }
Handles an upload
@param $uploader adapter following PHPCraft\Upload\UploadInterface
Handles an upload