File Upload Broke When Moving Windows To Linux

I love yii and deeply appreciate the help this forum has provided!

Admittedly my best programming days are behind me, but I have an issue that’s vexing me. I had this prototype running on my Windows 7 laptop (yii/php/apache/postgres), and when I went to move it to a linux server, my file uploads broke.

At first I thought it was the sessions, but I resolved that.

Then I thought it was permissions (the copied php files didn’t have the execute bit set), but that seems to be okay now.

Been fighting it for many hours now, and I can’t figure out what the issue is.

I have this in my "Files" controller for uploading & encrypting files:

public function actionCreate()


	$model=new Files;

	$securityManager =  new CSecurityManager;








		// The following encrypts the file.  

		$tmpfile = CUploadedFile::getInstance($model,'url');

		$tmpfile_contents = file_get_contents( $tmpfile->tempName );

		$encfile_contents = $securityManager->encrypt(base64_encode$tmpfile_contents));

		file_put_contents( $tmpfile->tempName, $encfile_contents );

		$model->filename = $model->url;



		// Create the directory if it doesn't exist

		if (is_dir(Yii::app()->basePath.'/datafiles/'.$pid)) {

			/* */

		} else {

			mkdir(Yii::app()->basePath.'/datafiles/'.$pid) ;



		if($model->save()) {


			//$model->url = $model->url;


		} else {


			throw new CHttpException(403,'Unable to save this file!');		



I originally had the "saveAs" before the "if($model->save)" and that yielded an encrypted file (in the final location) with a file name of "Object id #49" on linux, instead of "familypicutre.jpg" on Windows.

The behavior I am seeing is:

PHP error

Object of class CUploadedFile to string conversion

when it goes to do the validation during the save operation.

I also inserted a “var_dump($_FILES);die;” before the “save” on both Windows and linux, and they showed the exact same thing (other than the path diffs b/w the os’s).

It’s confusing, because the error looks like it’s at the yii level, so I don’t understand what the environment has to do with it. I think the real issue is that I don’t really understand how the $model->url can act as a filename as well as a CUploadedFile object, but I based this off of an example, and I got it to work in Windows…

Any ideas??? Thx!

OK! Found my answer at PHP version difference was killing me. Needed to set $model->filename to $tmpfile->name.