yii\web\UploadedFile::saveAs PHP 메소드

saveAs() 공개 메소드

Note that this method uses php's move_uploaded_file() method. If the target file $file already exists, it will be overwritten.
또한 보기: error
public saveAs ( string $file, boolean $deleteTempFile = true ) : boolean
$file string the file path used to save the uploaded file
$deleteTempFile boolean whether to delete the temporary file after saving. If true, you will not be able to save the uploaded file again in the current request.
리턴 boolean true whether the file is saved successfully
    public function saveAs($file, $deleteTempFile = true)
    {
        if ($this->error == UPLOAD_ERR_OK) {
            if ($deleteTempFile) {
                return move_uploaded_file($this->tempName, $file);
            } elseif (is_uploaded_file($this->tempName)) {
                return copy($this->tempName, $file);
            }
        }
        return false;
    }

Usage Example

예제 #1
5
 public function afterSave($insert, $changedAttributes)
 {
     $this->preview_input = UploadedFile::getInstance($this, 'preview_input');
     if (!empty($this->preview_input)) {
         $this->preview_input->saveAs($this->preview_picture);
     }
     parent::afterSave($insert, $changedAttributes);
 }
All Usage Examples Of yii\web\UploadedFile::saveAs