How to read content of uploaded file without of saving


I want to upload file, read the content, output it, but i don’t want to save this file on server

public function actionUpload()


    $model=new UploadForm;




	if($model->validate()) {


            //how to output content of uploaded file?




Is it right way?



The server can’t get the file’s contents, as the file resides on the client. You could simply remove the file after uploading it and getting its contents:

$uploadedFile = CUploadedFile::getInstance($model, 'file');

$newFilePath = "tmp/{$uploadedFile->name}";

$uploadSuccess = $uploadedFile->saveAs($newFilePath);

if (!$uploadSuccess) {

   throw new CHttpException('Error uploading file.');