SWFUpload is a small JavaScript/Flash library to get the best of both worlds. It features the great upload capabilities of Flash and the accessibility and ease of HTML/CSS now combined with the power of Yii framework.
'upload_success_handler'=>'js:uploadSuccessListView' TO 'upload_success_handler'=>'js:uploadSuccess'.
protected/extensionsSee the following code example:
On controller
$filedata=$_FILES['Filedata']; @move_uploaded_file($filedata['tmp_name'],'path/to/folder'); // Not relative. Full path
On Views
$this->widget('application.extensions.swfupload.CSwfUpload', array( 'jsHandlerUrl'=>'path/to/handler.js', //Relative path 'postParams'=>array(), 'config'=>array( 'use_query_string'=>true, 'upload_url'=>'/path/to/controller/action', //Use $this->createUrl method or define yourself 'file_size_limit'=>'2 MB', 'file_types'=>'*.jpg;*.png;*.gif', 'file_types_description'=>'Image Files', 'file_upload_limit'=>0, 'file_queue_error_handler'=>'js:fileQueueError', 'file_dialog_complete_handler'=>'js:fileDialogComplete', 'upload_progress_handler'=>'js:uploadProgress', 'upload_error_handler'=>'js:uploadError', 'upload_success_handler'=>'js:uploadSuccess', 'upload_complete_handler'=>'js:uploadComplete', 'custom_settings'=>array('upload_target'=>'divFileProgressContainer'), 'button_placeholder_id'=>'swfupload', 'button_width'=>170, 'button_height'=>20, 'button_text'=>'<span class="button">'.Yii::t('messageFile', 'ButtonLabel').' (Max 2 MB)</span>', 'button_text_style'=>'.button { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 11pt; text-align: center; }', 'button_text_top_padding'=>0, 'button_text_left_padding'=>0, 'button_window_mode'=>'js:SWFUpload.WINDOW_MODE.TRANSPARENT', 'button_cursor'=>'js:SWFUpload.CURSOR.HAND', ), ) ); <?php echo CHtml::beginForm(); <div class="form"> <div class="row"> <div id="divFileProgressContainer"></div> <div class="swfupload"><span id="swfupload"></span></div> </div> </div> <?php echo CHtml::endForm();
Total 8 comments
Any ideas about how to save files to database.....?
I always get alert message with "302" written in it after uploading file. Looks like my controller/action is not found. But I can easily access it with url. What can be wrong?
Like @tonydspaniard I also made some changes:
PM is you're interested in the code (I wouldn't like to post it as a new extension)
Hi! How can i use this with FBGallery?
actually i forgot the ...php.
thanks for comments. please could u forward the code to me?
you'd better never use short tag in php.
Thank you very much!
I had to include swfupload onto my new project and it was quite easy to implement.
I did a couple of changes though:
a) made handlers.js to be part of the assets as the images folder and its css b) in handlers.js i have changed the lines where it points to a specific location for pictures such as error.gif to a variable that i set to published assets. c) added support for button_image_url but hidden
it just works nice and smooth... thanks
if you want the code i forward it to you... just PM
Leave a comment
Please login to leave your comment.