╃巡洋艦㊣ 2011-03-03 22:00:11 14760次浏览 1条评论 6 1 0

SWFUpload是一种轻量的JavaScript/Flash库得到广大好评。它的特点是Flash强大的上传功能及现在的HTML/CSS轻松的与Yii框架结合。

感谢PRADHAN我提了一个错误。要摆脱它,如果你在之前下载的此扩展,只要对你的代码作如下修改:

'upload_success_handler'=>'js:uploadSuccessListView' TO 
'upload_success_handler'=>'js:uploadSuccess'.Requirements

需求

  • Yii 1.0 or above

安装

  • 解压文件至 protected/extensions
  • 使用方法如下:

使用

看下面的例子:

在控制器

$filedata=$_FILES['Filedata'];
@move_uploaded_file($filedata['tmp_name'],'path/to/folder'); // Not relative. Full pathOn 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(); ?>

详细信息:http://www.yiiframework.com/extension/swfupload

觉得很赞
您需要登录后才可以评论。登录 | 立即注册