Yii 1.1: ajaxuploader

This is meant to upload and resize an image via ajax
8 followers

Description

PLAESE DOWNLOAD THE ajaxuploader_1.2.zip (the updated version of this module) not the first one.

This module is for uploading and resizing an image through ajax. Both images are saved on the server. The UploadController.php saves the filename in the database. The module assumes that the model to save the image filename has Yii::app()->user->id as the PK. You can change it in the UploadController.

The validation for the file is done both server-side and client-side. The rules for the file to upload are done in the /ajaxuploader/models/UploadModel.php(server-side) rules and in the /ajaxuploader/assets/js/processupload.js(client-side). UploadModel extends CFormModel.

The DOM element to output the uploaded image to is #output in the /ajaxuploader/assets/js/processupload.js. Make an element in your view to have this id or uncomment line 48 in /ajaxuploader/widgets/views/uploadform.php(to output the image on the modal)

Requirements

Tested with Yii 1.1.13 but should work with earlier versions.

Yii bootstrap 2.3 or above

Usage

Extract the files under /protected/modules.

Import the following in the /protected/config/main.php

array(
 'import'=>array(
'application.modules.ajaxuploader.widgets.*',
        'application.modules.ajaxuploader.controllers.*',
        'application.modules.ajaxuploader.models.*',
),
 
 
'modules'=>array(
/*
    * configuration for ajaxuploader
    */  
     'ajaxuploader'=>array(
        'userModel'=>'Biodata',  //change to the model that has the pix column
        'userPixColumn'=>'pix',  //column to save the filename
       'folder'=>'images', //the dest folder(should be in the same folder level as protected folder)
 
     ),
),

The upload form is in bootstrap modal. so add this to the htmlOptions of any element that would be clicked to trigger the modal

(data-target="#upload" data-toggle="modal")  // the id of the modal is #upload

Add this widget to the view where you have the above

<?php
         $this->widget('Uploader');  //for the upload form       
 ?>

Resources

External resources for this extension...

Total 6 comments

#17191 report it
amanation at 2014/05/11 03:36pm
Re:Yii 1.1.14 issue: include(TbButton.php) - partially solved

Hi raynox,

First for you to have $this->widget("TbProgress") without the bootstrap.widgets prefix, you must import all bootstrap widgets. So, in your config/main import all bootstrap widgets like this:

import=>array(
           'ext.bootstrap.widgets.*',
)

Then as par the error

jQuery('#upload').modal({'show':false}); -"undifined is not a function"

It shows up because your bootstrap javascript is not properly installed, so the modal function is not included. What version of yii bootstrap are you using? Did you carefully follow the steps outlined to install it?

Amamba

#17153 report it
raynox at 2014/05/07 09:26pm
Yii 1.1.14 issue: include(TbButton.php) - partially solved

Hello again guys,

I noticed that my file uploadform.php under modules/ajaxuploader/widgets/views didn't have bootstrap.widgets referenced.. That is, while others were like $this->widget('bootstrap.widgets.TbProgress'.... I have to add to $this->widget('TbButton'.. the prefix bootstrap.widgets that was missing (dunno why!).

Anyway I'm now facing another problem. I can load the page for the file upload but it doesn't work. In Chrome debug console I get this javascript error: jQuery('#upload').modal({'show':false}); -"undifined is not a function" I think it's related to the fact that I did not implement this part:

"The upload form is in bootstrap modal. so add this to the htmlOptions of any element that would be clicked to trigger the modal" (data-target="#upload" data-toggle="modal") // the id of the modal is #upload

I didn't understand what one has to do here.

Any suggestions ?

Thanks a lot !

#17152 report it
raynox at 2014/05/07 09:04pm
Yii 1.1.14 issue: include(TbButton.php)

Hello guys,

I'm using Yii 1.1.14 and I installed the bootstrap file yii-bootstrap-2.1.0.r355.zip . I configured my main.php files (and others) as explained in here and in this same page I'm posting.

For some reason when I access my view to upload a file I keep getting the error:

include(TbButton.php) [function.include]: failed to open stream: No such file or directory ....framework\YiiBase.php(427)

I have a model that as the id PK nameed id_ficheiro and also changed this under UploadController. Also I uncommented line 48 in /ajaxuploader/widgets/views/uploadform.php(to output the image on the modal).

Does any of you gurus have any idea what I might be doing wrong ?

Thank you very much !

Best Regards.

#16764 report it
Mozammel Haque at 2014/03/26 01:22am
Problem To Integrate this Module

Dear Ama, Thanks a lot. I solved my problem, this problem was in Yii 1.1.14 version. Now It is running in 1.1.8 version. Thanks again.

#16761 report it
amanation at 2014/03/25 04:40pm
Re: Problem to Integrate this Module

Hi Haque, The page doesn't show because only ajax requests are accepted. Just follow the steps outlined and it should work.

#16709 report it
Mozammel Haque at 2014/03/21 12:44pm
Problem To Integrate this Module

Dear Friends, I'm facing some problem to integrate this module. I coppied all file in model,controller and view, But when i want to visit "http://localhost/yii2/yii2/index.php?r=upload/Process" It doesn't show anything. Please can anyone let me know what is the problem, I'm new in Yii Framework. Thanks All.

Leave a comment

Please to leave your comment.

Create extension