src/net/Flow.php
public function save ($name = null)
		{
			if ($name == null)
				$name = StringHelper::random();

			$ext = pathinfo($this->_params[ 'filename' ], PATHINFO_EXTENSION);
			$this->_savedFilename = $name . '.' . $ext;
			if (( $file = fopen($this->_targetDir . '/' . $this->_savedFilename, 'w') ) !== false)
			{
				if (Yii::$app->settings->get('upload_concat') == 'cat')
				{
					fclose($file);
					setlocale(LC_ALL, 'ru_RU.UTF-8');
					for ($i = 1; $i <= $this->_params[ 'totalChunks' ]; $i++)
						shell_exec('cat ' . escapeshellarg($this->getChunkPath($i)) . ' >> ' . escapeshellarg($this->_targetDir . '/' . $this->_savedFilename));
					setlocale(LC_ALL, null);
				}
				else
				{
					for ($i = 1; $i <= $this->_params[ 'totalChunks' ]; $i++)
						fwrite($file, file_get_contents($this->getChunkPath($i)));
					fclose($file);
				}
			}
			FileHelper::removeDirectory($this->_tmpDir);

			return $this->_savedFilename;
		}
public function save ($name = null)
		{
			if ($name == null)
				$name = StringHelper::random();

			$ext = pathinfo($this->_params[ 'filename' ], PATHINFO_EXTENSION);
			$this->_savedFilename = $name . '.' . $ext;
			if (( $file = fopen($this->_targetDir . '/' . $this->_savedFilename, 'w') ) !== false)
			{
				if (Yii::$app->settings->get('upload_concat') == 'cat')
				{
					fclose($file);
					setlocale(LC_ALL, 'ru_RU.UTF-8');
					for ($i = 1; $i <= $this->_params[ 'totalChunks' ]; $i++)
						shell_exec('cat ' . escapeshellarg($this->getChunkPath($i)) . ' >> ' . escapeshellarg($this->_targetDir . '/' . $this->_savedFilename));
					setlocale(LC_ALL, null);
				}
				else
				{
					for ($i = 1; $i <= $this->_params[ 'totalChunks' ]; $i++)
						fwrite($file, file_get_contents($this->getChunkPath($i)));
					fclose($file);
				}
			}
			FileHelper::removeDirectory($this->_tmpDir);

			return $this->_savedFilename;
		}
public function save ( $ name = null ) { if ( $ name == null ) $ name = StringHelper :: random ( ) ; $ ext = pathinfo ( $ this -> _params [ 'filename' ] , PATHINFO_EXTENSION ) ; $ this -> _savedFilename = $ name . '.' . $ ext ; if ( ( $ file = fopen ( $ this -> _targetDir . '/' . $ this -> _savedFilename , 'w' ) ) !== false ) { if ( Yii :: $ app -> settings -> get ( 'upload_concat' ) == 'cat' ) { fclose ( $ file ) ; setlocale ( LC_ALL , 'ru_RU.UTF-8' ) ; for ( $ i = 1 ; $ i <= $ this -> _params [ 'totalChunks' ] ; $ i ++ ) shell_exec ( 'cat ' . escapeshellarg ( $ this -> getChunkPath ( $ i ) ) . ' >> ' . escapeshellarg ( $ this -> _targetDir . '/' . $ this -> _savedFilename ) ) ; setlocale ( LC_ALL , null ) ; } else { for ( $ i = 1 ; $ i <= $ this -> _params [ 'totalChunks' ] ; $ i ++ ) fwrite ( $ file , file_get_contents ( $ this -> getChunkPath ( $ i ) ) ) ; fclose ( $ file ) ; } } FileHelper :: removeDirectory ( $ this -> _tmpDir ) ; return $ this -> _savedFilename ; }
Saves uploaded file.
@param null|string $name File name (without extension).
@return string Saved file name with extension.
@throws \yii\base\ErrorException
Saves uploaded file .