EAjaxUpload Extension

I have installed the EAjaxUpload Extension. Could not find any entries using search - so a new topic. Was not able to post against the entry in Extensions.

The page prompts for a file, it downloads with progress but at the end it just says "Failed."

I have tried placing "upload" folders everywhere in case I created in the wrong directory. I cannot much information on this extension, but I would like to use this as it seems to be the most compact.

Any help would be appreciated.

Hello. I’m the author of this extension. Please describe as fully as possible what you have a problem?

Hi, thanks for the assistance. I have a simple site that I requires an upload feature. I have loaded the extension as instructed. The upload button appears on the view and I can select a file. It goes though the process of uploading and then it lists the file with a "Failed." response. I have not been able to debug as the transaction happens outside of YIi/PHP and is between the OS and the Browser.

I have tried to add "upload" directory in a number of spots but cannot find any instruction as to where exactly to locate. The other question is where is the temporary file saved? Does another directory need to be created with write permissions?

Thanks again.

Micheal

Kosenka,

Further to the above. I had a look at the ‘valums.com/ajax-upload’ site to see what I could find.

I was able to trace down to the following;

‘action’=>’/controller/upload’

I am changing the word controller to ‘/accreditation/upload’; as I had added the actionUpload() to my AccreditationController.php.

The error is that I get a 404 error ‘upload’; not found.

I hope that is enough information for you to point me in the right direction. It’s very close now.

I would also like to know where to place the default folder ‘uploads’.

Thanks again.

Micheal

Try to open in the browser: http://[you’r_site]/accreditation/upload

Will there be any errors?

I had to include the folder and index.php (/narta/index.php/accreditation/upload) and got the following;

[uploader] responseText = {‘error’:‘increase post_max_size and upload_max_filesize to 10M’}

Here are my configuration files;

{view}.php


<?php $this->widget('ext.EAjaxUpload.EAjaxUpload',

				                 array(

				                       'id'=>'uploadFile',

				                       'config'=>array(

				                                       'action'=>'/narta/index.php/accreditation/upload',

				                                       'allowedExtensions'=>array("jpg","jpeg","gif","pdf","png"), //and etc...

				                                       'sizeLimit'=>10*1024*1024,// maximum file size in bytes

				                                       'minSizeLimit'=>1,// minimum file size in bytes

				                                       'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",

				                                       'messages'=>array(

				                                                         'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",

				                                                         'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",

				                                                         'minSizeError'=>"{file} is too small, minimum file size is {minSizeLimit}.",

				                                                         'emptyError'=>"{file} is empty, please select files again without it.",

				                                                         'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."

				                                                      ),

				                                       'showMessage'=>"js:function(message){ alert(message); }"

				                                      )

				                      ));

			?>

AccreditationController.php


	public function actionUpload()

	{

		        Yii::import("ext.EAjaxUpload.qqFileUploader");


	                $folder='upload/';// folder for uploaded files

	                $allowedExtensions = array("jpg","jpeg","gif","png","pdf"); // and etc...

	                $sizeLimit = 10 * 1024 * 1024;// maximum file size in bytes

	                $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);

	                $result = $uploader->handleUpload($folder);

	                $result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);

	                echo $result;// it's array

	}



The test file is ‘logo.png 0.9kB’

Thanks in advance.

Micheal

This message: “[uploader] responseText = {‘error’: ‘increase post_max_size and upload_max_filesize to 10M’}” indicates that your server are restrictions on the size of an uploaded file.

Look in the php.ini: post_max_size, upload_max_filesize

Try to reduce the value of "sizeLimit" in EAjaxUpload.

OK I changed to 3MB and the error is;

increase post_max_size and upload_max_filesize to 3M

Any ideas?

Try to reduce to 1 MB and show me what settings are in php.ini in : "post_max_size" and "upload_max_filesize".

This is the problem. I changed to 1M and the file uploaded. Now it looks like I need to find my php.ini file on my VPS so I can upload larger files.

Thank you for you assistance.

Hi,

have also tried to get the extension run but i failed too.

Have got an http-error 403 if i call http://[you’r_site]/event/upload.

  1. Have added your code snipplet for the view

  2. Have added your code snipplet for the controller to EventController.php

    • Removed the litte type (, -> ; on line 6)
  3. Called http://[you’r_site]/event/upload and got 403 error.

Could you tell me where to create the ‘upload’-folder?

Have tried it with ../view/event/upload and set the permissions to 777 but that doesn’t work.

Could you please help.

THANKS

BJ

hello

i am newbie in yiiframework i installed your extension its working fine and thanks for the gr8 extension but

i have one issue i wanted to store all the file name in to database so not understand how to get all the file names and store it while submitting the form

if you could help me out i will be very thankful

as soon as possible give me reply its urgent

Hello everyone,

First of all, thanks for this extension, good job.

I have the same problem as @nadeem. In my case, image uploader should be part of form with many fields.

So I changed:


echo $form->textField($model,'banner',array('size'=>50,'maxlength'=>128)); 

into:




$this->widget('ext.EAjaxUpload.EAjaxUpload',

		array(

				'id'=>'uploadFile',

				'config'=>array(

					   'action'=>Yii::app()->baseUrl.'/content/upload',

					   	'allowedExtensions'=>array("jpg"),//array("jpg","jpeg","gif","exe","mov" and etc...

						'sizeLimit'=>10 * 1024 * 1024,// maximum file size in bytes

						'minSizeLimit'=>1*1024,// minimum file size in bytes

						'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",

						'messages'=>array(

					                    'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",

					                    'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",

					                    'minSizeError'=>"{file} is too small, minimum file size is {minSizeLimit}.",

					                    'emptyError'=>"{file} is empty, please select files again without it.",

					                    'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."

					                   ),

					  'showMessage'=>"js:function(message){ alert(message); }"

					  )

		));

This extension successfully upload image but does not enter the name of file in db. In other extensions(that I use in same form for other purposes), I simply include properities of this field:




 "model"=>$model,                 # Data-Model

 "attribute"=>'banner',           # Attribute in the Data-Model



and after pressing a button Save, script saves information in corresponding field in db.

But here I haven’t that option. How I could solve this? :unsure: :blink:

EAjaxUpload does not work with the database.

You must self to write code to save the file name in the database.

Aha, ok.

Is there any way I can get file name out of this widget in view file? Then I could pass that name as a value to db. =)

The widget transfers the file name to the controller. Look at the example of the controller here http://www.yiiframework.com/extension/eajaxupload/

Thanks for answer. I did not manage to find that place of code where I can pull out name of image file to db. Never mind. Thank you anyway.

I gave up from this extension and implemented this solution for image uploading.

Now I have some other problems with this suggestion, but that is a story for another post. :D

how to see the json response? i use this

‘onComplete’=>“js:function(id, fileName, responseJSON){ alert(responseJSON); }”,

but the result is [object Object]

thanks.

I try to use this extension but i only get "failed" when i upload an image

here is my code

UploadController.php


class UploadController extends Controller

{

	public function actionIndex()

	{

		$this->render('index');

	}

        

	public function actionUpload()

	{


		Yii::import("ext.EAjaxUpload.qqFileUploader");

	 

		$folder=Yii::app()->baseUrl.'upload/';// folder for uploaded files

		$allowedExtensions = array("jpg");//array("jpg","jpeg","gif","exe","mov" and etc...

		$sizeLimit = 10 * 1024 * 1024;// maximum file size in bytes

		$uploader = new qqFileUploader($allowedExtensions, $sizeLimit);

		$result = $uploader->handleUpload($folder);

		$result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);

		echo $result;// it's array

	}




}

site/index.php


	<? $this->widget('ext.EAjaxUpload.EAjaxUpload',

	array(

        'id'=>'uploadFile',

        'config'=>array(

               'action'=>Yii::app()->baseUrl.'UploadController',

               'allowedExtensions'=>array("jpg"),//array("jpg","jpeg","gif","exe","mov" and etc...

               'sizeLimit'=>10*1024*1024,// maximum file size in bytes

               'minSizeLimit'=>1*1*1024,// minimum file size in bytes

		//'folder'=>'../../images/',

               //'onComplete'=>"js:function(id, fileName, responseJSON){ alert(fileName); }",

               //'messages'=>array(

               //                  'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",

               //                  'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",

               //                  'minSizeError'=>"{file} is too small, minimum file size is {minSizeLimit}.",

               //                  'emptyError'=>"{file} is empty, please select files again without it.",

               //                  'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."

               //                 ),

               //'showMessage'=>"js:function(message){ alert(message); }"

              ),

	)); ?>

I need some help here please! :-[

I alsoo had some issues with this extension, and was about to give up, but finally managed to get it working, here are my steps, for those who need help:

  1. Make sure your upload folder exists and has the right chmod properties (set it on 777 first, and if you got it working set it on 775). the upload folder should be in the root of the site.

  2. I had issues with "file not found controller/upload/". My Yii app was in a subfolder for testing. Once I put it in the root (in my case I put it in a subdomain folder). It worked. This could be a pathing issue from my side. but it worked.

  3. Adjust the php.ini with:

upload_max_filesize = 10M

post_max_size = 10M

if you dont have a php.ini. Create one and put it in the root of your site (or wherever your hostingprovider wants it).

This is my code:

the view (index.php in my case)


<? $this->widget('ext.EAjaxUpload.EAjaxUpload',

array(

        'id'=>'uploadFile',

        'config'=>array(

               'action'=>'/Builder/CreateThumb',

               'allowedExtensions'=>array("jpg"),//array("jpg","jpeg","gif","exe","mov" and etc...

               'sizeLimit'=>10*1024*1024,// maximum file size in bytes

               'minSizeLimit'=>1024,// minimum file size in bytes

               'onComplete'=>"js:function(id, fileName, responseJSON){ console.log(responseJSON); }",

               'messages'=>array(

                                 'typeError'=>"{file} has invalid extension. Only {extensions} are allowed.",

                                 'sizeError'=>"{file} is too large, maximum file size is {sizeLimit}.",

                                 'minSizeError'=>"{file} is too small, minimum file size is {minSizeLimit}.",

                                 'emptyError'=>"{file} is empty, please select files again without it.",

                                 'onLeave'=>"The files are being uploaded, if you leave now the upload will be cancelled."

                                ),

               'showMessage'=>"js:function(message){ alert(message); }"

              )

)); ?>

the controller (in my case BuilderController)

<?php


class BuilderController extends Controller

{

    public function actionCreateThumb(){

        

         Yii::import("ext.EAjaxUpload.qqFileUploader");


        $folder='var/projects/';// folder for uploaded files

        $allowedExtensions = array("jpg");//array("jpg","jpeg","gif","exe","mov" and etc...

        $sizeLimit = 10 * 1024 * 1024;// maximum file size in bytes

        $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);

        $result = $uploader->handleUpload($folder);

        $result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);

        echo $result;// it's array

    }

}

regardds,

Zephyr