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.
Resources ¶
Donate ¶
Documentation ¶
THANKS TO PRADHAN WHO TOLD ME ABOUT ONE BUG. TO GET RID OF IT, IF YOU HAVE DOWNLOADED THE EXTENSION BEFORE, JUST CHANGE ONE LINE ON YOUR CODE: ¶
'upload_success_handler'=>'js:uploadSuccessListView' TO 'upload_success_handler'=>'js:uploadSuccess'.
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/extensions
- Put the code bellow and
Usage ¶
See the following code example:
On controller
$filedata=$_FILES['Filedata'];
@move_uploaded_file($filedata['tmp_name'],'path/to/folder'); // Not relative. Full path
On Views
<?php
$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(); ?>
Change Log ¶
July 16, 2010 ¶
- Initial release.
July 25, 2010 ¶
- Solved bug on javascript handlers example file.
grrreat!
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
you made a bad example of this with short tag of php
<? $this->widget
you'd better never use short tag in php.
hey
thanks for comments. please could u forward the code to me?
e6nian
actually i forgot the ...php.
FBGallery
Hi!
How can i use this with FBGallery?
Cleanup
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)
302 error
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?
Database
Any ideas about how to save files to database.....?
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.