frontend/modules/elfind/src/elFinderVolumeLocalFileSystem.class.php
/**
     * Create new file and write into it from file pointer.
     * Return new file path or false on error.
     *
     * @param  resource  $fp   file pointer
     * @param  string    $dir  target dir path
     * @param  string    $name file name
     * @param  array     $stat file stat (required by some virtual fs)
     * @return bool|string
     * @author Dmitry (dio) Levashov
     **/
Create new file and write into it from file pointer.
Return new file path or false on error.


Create new file and write into it from file pointer . Return new file path or false on error .
protected function _save($fp, $dir, $name, $stat) {
        $path = $this->_joinPath($dir, $name);
        $meta = stream_get_meta_data($fp);
        $uri = isset($meta['uri'])? $meta['uri'] : '';
        if ($uri && ! preg_match('#^[a-zA-Z0-9]+://#', $uri)) {
            fclose($fp);
            $mtime = filemtime($uri);
            $isCmdPaste = ($this->ARGS['cmd'] === 'paste');
            $isCmdCopy = ($isCmdPaste && empty($this->ARGS['cut']));
            if (($isCmdCopy || !rename($uri, $path)) && !copy($uri, $path)) {
                return false;
            }
            if ($mtime && $this->ARGS['cmd'] === 'upload' && isset($this->options['keepTimestamp']['upload'])) {
                touch($path, $mtime);
            }
            $isCmdPaste && !$isCmdCopy && touch($uri);
        } else {
            if (file_put_contents($path, $fp, LOCK_EX) === false) {
                return false;
            }
        }
        if (is_link($path)) {
            unlink($path);
            return $this->setError(elFinder::ERROR_SAVE, $name);
        }
        chmod($path, $this->options['fileMode']);
        clearstatcache();
        $regEvent = $this->registerUploadEvent($path);
        foreach ($regEvent['event_data'] as $k => $v) {
            array_push(parent::$event_data, $regEvent['event_data'][$k]);
        }
        return $regEvent['path'];
    }
protected function _save ( $ fp , $ dir , $ name , $ stat ) { $ path = $ this -> _joinPath ( $ dir , $ name ) ; $ meta = stream_get_meta_data ( $ fp ) ; $ uri = isset ( $ meta [ 'uri' ] ) ? $ meta [ 'uri' ] : '' ; if ( $ uri && ! preg_match ( '#^[a-zA-Z0-9]+://#' , $ uri ) ) { fclose ( $ fp ) ; $ mtime = filemtime ( $ uri ) ; $ isCmdPaste = ( $ this -> ARGS [ 'cmd' ] === 'paste' ) ; $ isCmdCopy = ( $ isCmdPaste && empty ( $ this -> ARGS [ 'cut' ] ) ) ; if ( ( $ isCmdCopy || ! rename ( $ uri , $ path ) ) && ! copy ( $ uri , $ path ) ) { return false ; } if ( $ mtime && $ this -> ARGS [ 'cmd' ] === 'upload' && isset ( $ this -> options [ 'keepTimestamp' ] [ 'upload' ] ) ) { touch ( $ path , $ mtime ) ; } $ isCmdPaste && ! $ isCmdCopy && touch ( $ uri ) ; } else { if ( file_put_contents ( $ path , $ fp , LOCK_EX ) === false ) { return false ; } } if ( is_link ( $ path ) ) { unlink ( $ path ) ; return $ this -> setError ( elFinder :: ERROR_SAVE , $ name ) ; } chmod ( $ path , $ this -> options [ 'fileMode' ] ) ; clearstatcache ( ) ; $ regEvent = $ this -> registerUploadEvent ( $ path ) ; foreach ( $ regEvent [ 'event_data' ] as $ k => $ v ) { array_push ( parent :: $ event_data , $ regEvent [ 'event_data' ] [ $ k ] ) ; } return $ regEvent [ 'path' ] ; }
Create new file and write into it from file pointer.
Create new file and write into it from file pointer .
// keep timestamp on upload // re-create the source file for remove processing of paste command //return $path;