关于swfupload扩展的问题!急! [ 新手入门 ]
view代码如下:
<?php
$this->widget('application.extensions.swfupload.CSwfUpload', array(
'jsHandlerUrl'=>'assets/handler.js', //Relative path
'postParams'=>array(),
'config'=>array(
'use_query_string'=>true,
'upload_url'=>$this->createUrl('s/up'), //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(); ?>
现在我的页面打开什么都不显示,也不报错,请问各路大神,这是为什么啊?文件配置都是正确的。
共 11 条回复
-
我测试的view页面
<? $this->widget('application.extensions.swfupload.CSwfUpload', array( 'jsHandlerUrl'=>Yii::app()->assetManager->getBaseUrl().'/8d3fb39e/handlers.js', //Relative path 'postParams'=>array(), 'config'=>array( 'use_query_string'=>true, 'upload_url'=>$this->createUrl('site/test'), 'file_size_limit'=>'2 MB', 'file_types'=>'*.jpg;*.png;*.gif;', //'file_types'=>'*.txt;', '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'=>200, 'button_height'=>20, 'button_text'=>'<span class="button">'.Yii::t('messageFile', '请选择要上传的文件').' (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(); ?>
在浏览器里面显示出来后,你查看源代码,看头部那些JS,有没有引用相对应的JS进来,主要是看引用的地址是不是正确的。
-
我又纠结了一会。貌似解决了那个相对位置的问题了。不知道对不对。
view里面的相对位置就这么写(我下的'handlers.js'和'swfupload.js'都放在 protected\extensions\swfupload\assets 文件夹下)
'jsHandlerUrl'=>'handlers.js'
,然后修改CSwfUpload.php文件中的第十五行//Yii::app()->clientScript->registerScriptFile($this->jsHandlerUrl); Yii::app()->clientScript->registerScriptFile($baseUrl.'/'.$this->jsHandlerUrl);
这样生成的页面中的源代码是
<script type="text/javascript" src="/zcyxm/assets/8d3fb39e/swfupload.js"></script> <script type="text/javascript" src="/zcyxm/assets/8d3fb39e/handlers.js"></script>
drop0118
注册时间:2011-03-29
最后登录:2013-10-18
在线时长:0小时0分
最后登录:2013-10-18
在线时长:0小时0分
- 粉丝0
- 金钱160
- 威望0
- 积分160