Yii Framework Forum: SWFUpload Issues an Usage Discussion - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

SWFUpload Issues an Usage Discussion Rate Topic: -----

#1 User is offline   thiagovidal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 17-February 10
  • Location:Brazil, São Paulo

Posted 16 July 2010 - 11:45 AM

Just relesed the SwfUpload extension.
0

#2 User is offline   Deepak Pradhan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 209
  • Joined: 01-May 09
  • Location:Charlotte, NC

Posted 24 July 2010 - 11:21 AM

I would like to try this extension but I keep getting error 500
0

#3 User is offline   thiagovidal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 17-February 10
  • Location:Brazil, São Paulo

Posted 24 July 2010 - 11:45 AM

View PostPradhan, on 24 July 2010 - 11:21 AM, said:

I would like to try this extension but I keep getting error 500


Some questions...

Did you enabled Yii CSRF?
Could you post your code for me? (Controller, Model and View)
0

#4 User is offline   Deepak Pradhan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 209
  • Joined: 01-May 09
  • Location:Charlotte, NC

Posted 25 July 2010 - 01:15 AM

Sure man! thanks for reverting to the problem. Please note, I am not using the model.

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
0

#5 User is offline   thiagovidal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 17-February 10
  • Location:Brazil, São Paulo

Posted 25 July 2010 - 10:01 AM

Sorry dude. The follow script i wrote to update one Yii CListView after download. You are right, use the uploadSuccess for regular purposes.

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.
0

#6 User is offline   zegarmistrz001 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 06-April 09

Posted 13 October 2010 - 08:28 AM

I get a 302 error

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');?>

0

#7 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 17 October 2010 - 03:58 AM

View Postzegarmistrz001, on 13 October 2010 - 08:28 AM, said:

I get a 302 error



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!
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#8 User is offline   zegarmistrz001 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 06-April 09

Posted 19 October 2010 - 05:47 AM

Thanks for your help. Now it is working fine.
0

#9 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 20 October 2010 - 12:59 PM

View Postzegarmistrz001, on 19 October 2010 - 05:47 AM, said:

Thanks for your help. Now it is working fine.


Not a problem! I am glad it worked for you too... The developer should include this info into the Extension details.

Best
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#10 User is offline   bwong3351 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 21-October 10

Posted 21 October 2010 - 02:05 PM

First thank you for the great widget.

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
0

#11 User is offline   thiagovidal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 17-February 10
  • Location:Brazil, São Paulo

Posted 21 October 2010 - 03:19 PM

View Postbwong3351, on 21 October 2010 - 02:05 PM, said:

First thank you for the great widget.

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!
0

#12 User is offline   thiagovidal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 17-February 10
  • Location:Brazil, São Paulo

Posted 21 October 2010 - 03:20 PM

View PostAntonio Ramirez, on 20 October 2010 - 12:59 PM, said:

Not a problem! I am glad it worked for you too... The developer should include this info into the Extension details.

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!
0

#13 User is offline   bwong3351 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 21-October 10

Posted 21 October 2010 - 03:42 PM

View Postthiagovidal, on 21 October 2010 - 03:19 PM, said:

Thanks dude! I think you should talk to your server to check the size limit of uploads. But I will check it anyway!


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.
0

#14 User is offline   thiagovidal 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 147
  • Joined: 17-February 10
  • Location:Brazil, São Paulo

Posted 21 October 2010 - 04:29 PM

View Postbwong3351, on 21 October 2010 - 03:42 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.


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/
1

#15 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 22 October 2010 - 06:46 AM

I see the same problems here that occurs with swfupload plugin when programming in javascript. It could be good that we include the possible problems and solutions within A PROBLEMS_SOLUTIONS.TXT file in the packaged document.

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
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#16 User is offline   Francis.TM 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 55
  • Joined: 19-April 10
  • Location:China. RP.

Posted 31 January 2011 - 03:43 AM

unable to login with PHPSESSID. how to solve that?
0

#17 User is offline   Nacesprin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 04-April 10
  • Location:San Fernando - Cadiz - Spain

Posted 31 January 2011 - 12:21 PM

Hello people!

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?
0

#18 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,450
  • Joined: 04-October 10

Posted 31 January 2011 - 06:25 PM

It seems that SwfUpload had a problem on that matter before: http://code.google.c...es/detail?id=69
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#19 User is offline   Nacesprin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 71
  • Joined: 04-April 10
  • Location:San Fernando - Cadiz - Spain

Posted 01 February 2011 - 01:00 PM

View PostAntonio Ramirez, on 31 January 2011 - 06:25 PM, said:

It seems that SwfUpload had a problem on that matter before: http://code.google.c...es/detail?id=69

Yes but that issue appears is closed and not solved.
0

#20 User is offline   chriscao 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 43
  • Joined: 03-February 10

Posted 18 May 2011 - 06:37 AM

I would like to use SWFupload in the form, just like formsdemo. After submit button is clicked, the file selected starts uploading. But the file uploading could not be completed.

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();
} 

0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users