Yii Uploadify plugin

I have seen through uploadify wrappers for yii and none of them are that flexible. They also haven’t been updated since 2009. So I thought of creating my own.

Here is what I have done. Its just a beta release and might require modification. Please comment and help me improve. What I want is to develop a complete solution for uploadify.

Thanks

fr3ak

Sorry forgot to post the usuage instruction.

To place the uploadify button.




<?php $this->widget('application.extensions.uploadifysazilo.uploadifysaziloWidget', 

						array('multi'=>'true',

						      'uploadScript'=>'upload/upload', //Controller and action to be performed

						      'onCompleteJs'=>'alert(response);',

						      'autoUpload'=>'false')); ?>






Other options are:

public $multi;				//Multiple support or not. Allowed value: true or false. Default value is false

		public $uploaderPath;		//Uploader swf path. The default path is extensionpath/swf/uploader.swf

		public $cancelImage;		//Cancel image used by uploadify. The default path is extensionpath/images/cancel.png

		public $uploadScript;		//Upload script should be present. It is the script(controller) that handles the main file upload event and does the takss like moving the file to respective path.

		public $uploadFolder;		//The folder where the file is to be uploaded

		public $fileDescription;	//The file description that is to be shown on the file dialog. Default value is "Image Files"

		public $fileExtension;		//The file extension allowed. Default value is "*.jpg;*.jpeg;*.gif;*.png"

		public $buttonText;			//Text to be shown in the Upload button. Default value is "Upload"

		public $simUploadLimit;		//Maximum simultaneous upload. Default value is "1"

		public $onCompleteJs;		//The javascript to be executed after successful upload withour the <script> tag.

		public $autoUpload;			//AutoUpload: Allowed true or false. Default value is true



Now you have to place the code to handle fileUpload in a controller. Something like this:




if (!empty($_FILES)) {

			$tempFile = $_FILES['Filedata']['tmp_name'];

			//echo $_SERVER['DOCUMENT_ROOT'];

			$targetPath = $_SERVER['DOCUMENT_ROOT'].Yii::app()->baseUrl . '/images/gallery/';


			$ext = substr($_FILES['Filedata']['name'], -3);

			$folder = time().rand();

			$folderPath = $targetPath . $folder;

			$newFileName = $folder . '.' . $ext;

			$targetFile =  str_replace('//','/',$targetPath) . $newFileName;


			mkdir(str_replace('//','/',$folderPath), 0755, true);

			move_uploaded_file($tempFile,$targetFile);

			echo CHtml::asset($targetFile);

		}



is this working with you?