Yii Framework Forum: Yii Uploadify plugin - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Uploadify plugin

#1 User is offline   fr34k 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 05-May 11

Posted 05 May 2011 - 01:21 AM

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.


Sorry forgot to post the usuage instruction.

To place the uploadify button.

<?php $this->widget('application.extensions.uploadifysazilo.uploadifysaziloWidget', 
						      'uploadScript'=>'upload/upload', //Controller and action to be performed
						      '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);
			echo CHtml::asset($targetFile);

Attached File(s)


#2 User is offline   sotty 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 15-May 11

Posted 06 June 2011 - 05:07 AM

is this working with you?

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users