SWFUpload Issues an Usage Discussion
#4
Posted 25 July 2010 - 01:15 AM
View:
note: 'upload_success_handler'=>'js:uploadSuccessListView' gives error
uploadSuccessListView is not defined http://localhost/gfi...r/upload_images Line 75
I changed that line to : 'upload_success_handler'=>'js:uploadSuccess'
<?php $handlers_js = URL_BASE.'js/handlers.js'; Yii::app()->clientScript->registerScriptFile($handlers_js,CClientScript::POS_HEAD); ?> <?php $this->widget('application.extensions.swfupload.CSwfUpload', array( 'postParams'=>array(), 'config'=>array( 'use_query_string'=>true, 'upload_url'=>$this->createUrl('/garage/seller/actionupload'), '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_success_handler'=>'js:uploadSuccessListView', '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(); ?>
My Controller looks like this:
protected function actionUpload() { $filedata=$_FILES['Filedata']; @move_uploaded_file($filedata['tmp_name'],'C:/www/home/gfied/test.jpg'); // Not relative. Full path } public function actionUpload_images() { $this->render('upload_images'); }
No error now, I have set enableCsrfValidation=true.
** But Image is not saving in the designated folder. **
Thanks
#5
Posted 25 July 2010 - 10:01 AM
function uploadSuccessListView(file, serverData) { try { var progress = new FileProgress(file, this.customSettings.upload_target); if (serverData.substring(0, 2) === "OK") { $.fn.yiiListView.update('listview'); } else { progress.setStatus("Error."); progress.toggleCancel(false); alert(serverData); } } catch (ex) { this.debug(ex); } }
About the file i tested here and it works fine. Strange... Keep trying... I lost one day fixing my code, now I know use it properly.
#6
Posted 13 October 2010 - 08:28 AM
My controller:
public function actionUploadLoga() { $fd = fopen("upload/t.txt",'w'); fwrite($fd,'zegar'); fclose($fd); $filedata=$_FILES['Filedata']; move_uploaded_file($filedata['tmp_name'],'/var/www/zegarmistrz/elipse/gg2/upload/1.jpg'); }
Unfortunately both files (t.txt and 1.jpg) are not created.
My view:
<?php $form = $this->beginWidget('CActiveForm',array( 'id'=>'wizytowka', 'enableAjaxValidation'=>false)); ?> <? $this->widget('application.extensions.swfupload.CSwfUpload', array( 'jsHandlerUrl'=>'javascript/handlers.js', //Relative path 'postParams'=>array(), 'config'=>array( 'use_query_string'=>true, 'upload_url'=>CHtml::normalizeURL(array('uzytkownicy/uploadLoga')), //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">Dodaj zdjęcie (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', ), ) ); ?> <div class="form"> <div class="row"> <div id="divFileProgressContainer"></div> <div class="swfupload"><span id="swfupload"></span></div> </div> </div> <?php $this->endWidget('CActioveForm');?>
#7
Posted 17 October 2010 - 03:58 AM
zegarmistrz001, on 13 October 2010 - 08:28 AM, said:
Just make sure that you remove accessControl to your upload function action!!
In my case was:
public function filters() { return array( 'accessControl -upload', // perform access control but for uploadAction ); }
Hope this helps you!
#9
Posted 20 October 2010 - 12:59 PM
#10
Posted 21 October 2010 - 02:05 PM
I did run into problem when using this - I can't upload any file larger then 100M even if I set all to following variables to 150M:
swfupload: file_size_limit
HTML form hidden MAX_FILE_SIZE
PHP memory_limit, upload_max_filesize and upload_max_size
Am I missing anything?
Thanks
#11
Posted 21 October 2010 - 03:19 PM
bwong3351, on 21 October 2010 - 02:05 PM, said:
I did run into problem when using this - I can't upload any file larger then 100M even if I set all to following variables to 150M:
swfupload: file_size_limit
HTML form hidden MAX_FILE_SIZE
PHP memory_limit, upload_max_filesize and upload_max_size
Am I missing anything?
Thanks
Thanks dude! I think you should talk to your server to check the size limit of uploads. But I will check it anyway!
#12
Posted 21 October 2010 - 03:20 PM
Antonio Ramirez, on 20 October 2010 - 12:59 PM, said:
Best
Yeah I will do this. Thanks for advice!
Actually I had this problem and disabled Yii Csrf to extension work now I know how to solve it. Thanks guys!
#13
Posted 21 October 2010 - 03:42 PM
thiagovidal, on 21 October 2010 - 03:19 PM, said:
Thank you for the quick response. The code is currently running on my dev machine's xampp therefore I don't have a upload limit. On top of it, a regular PHP post upload of 150M+ file seems to be fine. I even play with apache's LimitRequestBody directive with no success.
Thanks in advance.
#14
Posted 21 October 2010 - 04:29 PM
bwong3351, on 21 October 2010 - 03:42 PM, said:
Thanks in advance.
ops... now I don't know. Can you try at swfuplod support forum? Maybe its a plugin issue. I'm still trying to solve it.
Follow link http://www.swfupload.org/
#15
Posted 22 October 2010 - 06:46 AM
We have already found a couple here and if we do it this way, we could just improve the plugin making it better for everybody to understand and install and solve any possible problems.
Most common are:
Error 302 <--- redirection -solved here
Error 404 <--- url not found -this is easy right?
Error 500 <--- solved here
Error
Error
well, just google it out there and there a huge list. What do you think about it thiagovidal? By the way, thanks to save my time!
Great extension
#16
Posted 31 January 2011 - 03:43 AM
#17
Posted 31 January 2011 - 12:21 PM
I've detected an error in postParams:
If I set:
$postParams = array( 'one'=>'1', 'two'=>'2', 'three'=>'3' );
Next, in controller:
Yii::trace('ONE:'.$_POST['one'],'dblog'); Yii::trace('TWO:'.$_POST['two'],'dblog'); Yii::trace('THREE:'.$_POST['three'],'dblog');
I obtain:
ONE: 1&two=2&three=3
TWO: (empty)
THREE: (empty)
So..., it appears that all $postParams are joined in the first element.
Is that a Bug?
#18
Posted 31 January 2011 - 06:25 PM
#19
Posted 01 February 2011 - 01:00 PM
Antonio Ramirez, on 31 January 2011 - 06:25 PM, said:
Yes but that issue appears is closed and not solved.
#20
Posted 18 May 2011 - 06:37 AM
I modified the handlers.js according to the example, formsdemo. But 'swfu' could not be found!
function doSubmit(e) { if (formChecker != null) { clearInterval(formChecker); formChecker = null; } e = e || window.event; if (e.stopPropagation) { e.stopPropagation(); } e.cancelBubble = true; try { swfu.startUpload(); } catch (ex) { } return false; }
When I didn't use the submit button. The file was uploaded after selection at once. It works well!
function fileDialogComplete(numFilesSelected, numFilesQueued) { this.startUpload(); }