src/Utility/Import.php
protected function _uploadFile() : string
    {
        if (! is_string($this->request->getData('file.name'))) {
            return '';
        }

        if (! is_string($this->request->getData('file.tmp_name'))) {
            return '';
        }

        $uploadPath = $this->_getUploadPath();
        if ('' === $uploadPath) {
            return '';
        }

        $pathInfo = pathinfo($this->request->getData('file.name'));

        $filename = (string)preg_replace('/\W/', '_', $pathInfo['filename']);
        $filename = (string)preg_replace('/_+/', '_', $filename);
        $filename = trim($filename, '_');
        $extension = $pathInfo['extension'] ?? '';
        if (!empty($extension)) {
            $extension = '.' . $extension;
        }

        $path = sprintf(
            '%s%s_%s%s',
            $uploadPath,
            (new Time())->i18nFormat('yyyyMMddHHmmss'),
            $filename,
            $extension
        );

        if (! move_uploaded_file($this->request->getData('file.tmp_name'), $path)) {
            return '';
        }

        return $path;
    }
protected function _uploadFile() : string
    {
        if (! is_string($this->request->getData('file.name'))) {
            return '';
        }

        if (! is_string($this->request->getData('file.tmp_name'))) {
            return '';
        }

        $uploadPath = $this->_getUploadPath();
        if ('' === $uploadPath) {
            return '';
        }

        $pathInfo = pathinfo($this->request->getData('file.name'));

        $filename = (string)preg_replace('/\W/', '_', $pathInfo['filename']);
        $filename = (string)preg_replace('/_+/', '_', $filename);
        $filename = trim($filename, '_');
        $extension = $pathInfo['extension'] ?? '';
        if (!empty($extension)) {
            $extension = '.' . $extension;
        }

        $path = sprintf(
            '%s%s_%s%s',
            $uploadPath,
            (new Time())->i18nFormat('yyyyMMddHHmmss'),
            $filename,
            $extension
        );

        if (! move_uploaded_file($this->request->getData('file.tmp_name'), $path)) {
            return '';
        }

        return $path;
    }
protected function _uploadFile ( ) : string { if ( ! is_string ( $ this -> request -> getData ( 'file.name' ) ) ) { return '' ; } if ( ! is_string ( $ this -> request -> getData ( 'file.tmp_name' ) ) ) { return '' ; } $ uploadPath = $ this -> _getUploadPath ( ) ; if ( '' === $ uploadPath ) { return '' ; } $ pathInfo = pathinfo ( $ this -> request -> getData ( 'file.name' ) ) ; $ filename = ( string ) preg_replace ( '/\W/' , '_' , $ pathInfo [ 'filename' ] ) ; $ filename = ( string ) preg_replace ( '/_+/' , '_' , $ filename ) ; $ filename = trim ( $ filename , '_' ) ; $ extension = $ pathInfo [ 'extension' ] ?? '' ; if ( ! empty ( $ extension ) ) { $ extension = '.' . $ extension ; } $ path = sprintf ( '%s%s_%s%s' , $ uploadPath , ( new Time ( ) ) -> i18nFormat ( 'yyyyMMddHHmmss' ) , $ filename , $ extension ) ; if ( ! move_uploaded_file ( $ this -> request -> getData ( 'file.tmp_name' ) , $ path ) ) { return '' ; } return $ path ; }
Upload data file.

@return string
Upload data file .