Yii Framework Forum: [Extension] Xupload - Yii Framework Forum

Jump to content

  • (20 Pages)
  • +
  • « First
  • 10
  • 11
  • 12
  • 13
  • 14
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

[Extension] Xupload Rate Topic: ***** 1 Votes

#221 User is offline   xphoenyx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 24-August 12

Posted 02 October 2012 - 11:59 AM

View PostAsgaroth, on 02 October 2012 - 11:35 AM, said:

Nope, URL parameter of the widget, should point to the action that will handle your uploaded files, like moving them renaming them etc. now, in order to to that, an action needs to know where to put the file, and also whats the public url to access that file.

In the default XUploadAction (which is only an example of a basic base upload logic), receives this as parameters, path and public path respectively, however this action will only serve as a template for your own logic, as it doesnt saves anything to the database or do any other fancy stuff.

Take a look at the XUpload Workflow, which gives you more of an example.


OK, thanx, this was an useful info. I finally figured out, what was the problem: in FileManagerController, simply create new action 'Upload' and insert in it this code:
return array(
            'upload'=>array(
                'class'=>'xupload.actions.XUploadAction',
                'path'=>Yii::getPathOfAlias('webroot') . "/images",
                'publicPath'=>Yii::getPathOfAlias('webroot') . "/images",
            ),
        );

And of cource allow it in 'accessRules'.
Now, what means error: 'Empty file upload result'? Is that because I'm using model default template?
0

#222 User is offline   Asgaroth 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 17-July 09
  • Location:Bogota, Colombia

Posted 02 October 2012 - 01:03 PM

I dont know, where are you seeing this error?
- Extension: Dynamic DataProvider Behavior
- Extension: XUpload - jQuery File Upload Extension
- Extension: PhpQuickProfiler - A Web Log Router that will help you profile your application
- Extension: XDateView - A Date grouped Grid View
- Extension: Foundation - An easy to use, powerful, and flexible framework for building prototypes and production code on any kind of device.



- Wiki: How to generate Yii like Documentation
- Wiki: How to re enable logging during unit testing
0

#223 User is offline   xphoenyx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 13
  • Joined: 24-August 12

Posted 02 October 2012 - 04:09 PM

View PostAsgaroth, on 02 October 2012 - 01:03 PM, said:

I dont know, where are you seeing this error?


Directly in the upload block, where error messages are shown. No errors in console.

Attached File(s)


0

#224 User is offline   Rajib Rakhmit 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 10-October 11
  • Location:Bangladesh

Posted 02 October 2012 - 10:45 PM

I am getting a ERROR. Please help me.


ERROR IS "Property "xupload.url" is not defined.


My Controller Name is "XuploadController.php" and Code is
<?php

class XuploadController extends Controller
{
	public function actionIndex()
	{
		Yii::import("xupload.models.XUploadForm");
		
		$model = new xupload();
		
		$this -> render('index', array('model' => $model, ));
	}

	// Uncomment the following methods and override them if needed
	
	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			
			'upload'=>array(
                'class'=>'xupload.actions.XUploadAction',
                'path' =>Yii::app() -> getBasePath() . "/../uploads",
                'publicPath' => Yii::app() -> getBaseUrl() . "/uploads",
            ),
		);
	}
	
}


My Model Name is "xupload.php" and code is

<?php

/**
 * This is the model class for table "xupload".
 *
 * The followings are the available columns in table 'xupload':
 * @property integer $id
 * @property string $fileName
 * @property string $description
 * @property string $extraId
 */
class xupload extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return xupload the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'xupload';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id, fileName, description, extraId', 'required'),
			array('id', 'numerical', 'integerOnly'=>true),
			array('fileName, description', 'length', 'max'=>50),
			array('extraId', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, fileName, description, extraId', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'fileName' => 'File Name',
			'description' => 'Description',
			'extraId' => 'Extra',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('fileName',$this->fileName,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('extraId',$this->extraId,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}


And My Index page path is view/xupload/index.php and code is
<?php
$this->widget('xupload.XUpload', array(
		'url' => Yii::app()->createUrl("xupload/upload"),
		'model' => $model,
		'attribute' => 'file',
		'multiple' => true,
));
?>

0

#225 User is offline   Asgaroth 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 17-July 09
  • Location:Bogota, Colombia

Posted 02 October 2012 - 10:53 PM

View Postxphoenyx, on 02 October 2012 - 04:09 PM, said:

Directly in the upload block, where error messages are shown. No errors in console.


Take a look at the server response in your network tab
- Extension: Dynamic DataProvider Behavior
- Extension: XUpload - jQuery File Upload Extension
- Extension: PhpQuickProfiler - A Web Log Router that will help you profile your application
- Extension: XDateView - A Date grouped Grid View
- Extension: Foundation - An easy to use, powerful, and flexible framework for building prototypes and production code on any kind of device.



- Wiki: How to generate Yii like Documentation
- Wiki: How to re enable logging during unit testing
0

#226 User is offline   Asgaroth 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 17-July 09
  • Location:Bogota, Colombia

Posted 02 October 2012 - 10:57 PM

View PostRajib Rakhmit, on 02 October 2012 - 10:45 PM, said:

I am getting a ERROR. Please help me.


ERROR IS "Property "xupload.url" is not defined.

...



Well... your model (xupload) doesnt really have an 'url' attribute, it only has id, fileName, description and extraId, the default action (XUploadAction), its only there as an example of the action that should handle the file uploads, and it assumes the use of an XUploadForm which has the url attribute defined.

You are supposed to write your own upload action, with the logic that suits your task.
- Extension: Dynamic DataProvider Behavior
- Extension: XUpload - jQuery File Upload Extension
- Extension: PhpQuickProfiler - A Web Log Router that will help you profile your application
- Extension: XDateView - A Date grouped Grid View
- Extension: Foundation - An easy to use, powerful, and flexible framework for building prototypes and production code on any kind of device.



- Wiki: How to generate Yii like Documentation
- Wiki: How to re enable logging during unit testing
0

#227 User is offline   andrew1 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-May 12

Posted 10 October 2012 - 01:57 PM

Just started to use this great extension in my project yesterday. I have no problems with uploads, but am missing how to display and manage existing files in the target directory. I can see a download template hence there is obviously a convenient way to get the file list. Am wanting to use not just to upload but manage files - common requirement for sure.

Whats confusing me is the only place I can see so far to set the destination directory is within the upload action set by url paramater for the xupload widget. Am digging deeper but would love a little timely help of convenient.

Cheers
Andrew
0

#228 User is offline   Asgaroth 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 17-July 09
  • Location:Bogota, Colombia

Posted 10 October 2012 - 02:07 PM

View PostAsgaroth, on 27 September 2012 - 10:11 AM, said:

I think someone already tried that. check this, -and its related- post



View Postandrew1, on 10 October 2012 - 01:57 PM, said:

Just started to use this great extension in my project yesterday. I have no problems with uploads, but am missing how to display and manage existing files in the target directory. I can see a download template hence there is obviously a convenient way to get the file list. Am wanting to use not just to upload but manage files - common requirement for sure.

Whats confusing me is the only place I can see so far to set the destination directory is within the upload action set by url paramater for the xupload widget. Am digging deeper but would love a little timely help of convenient.

Cheers
Andrew


Good luck!
- Extension: Dynamic DataProvider Behavior
- Extension: XUpload - jQuery File Upload Extension
- Extension: PhpQuickProfiler - A Web Log Router that will help you profile your application
- Extension: XDateView - A Date grouped Grid View
- Extension: Foundation - An easy to use, powerful, and flexible framework for building prototypes and production code on any kind of device.



- Wiki: How to generate Yii like Documentation
- Wiki: How to re enable logging during unit testing
0

#229 User is offline   andrew1 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-May 12

Posted 10 October 2012 - 03:15 PM

Hi Asgaroth

Am investigating that now. Hope it is alright to ask this here - is there a suitable paypal donation to this project that would help to get your help with this?
0

#230 User is offline   Asgaroth 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 17-July 09
  • Location:Bogota, Colombia

Posted 10 October 2012 - 03:25 PM

View Postandrew1, on 10 October 2012 - 03:15 PM, said:

Hi Asgaroth

Am investigating that now. Hope it is alright to ask this here - is there a suitable paypal donation to this project that would help to get your help with this?


There is not, sadly.

Apart from you there have been some people asking this, so after your question I added a task to my TODOs, and will be writing a wiki, however I can't give you an ETA, this is something I personally have never required, so id have to find some free time to check it out, test it, document and then actually write the wiki.
- Extension: Dynamic DataProvider Behavior
- Extension: XUpload - jQuery File Upload Extension
- Extension: PhpQuickProfiler - A Web Log Router that will help you profile your application
- Extension: XDateView - A Date grouped Grid View
- Extension: Foundation - An easy to use, powerful, and flexible framework for building prototypes and production code on any kind of device.



- Wiki: How to generate Yii like Documentation
- Wiki: How to re enable logging during unit testing
0

#231 User is offline   andrew1 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-May 12

Posted 10 October 2012 - 03:37 PM

very sad :-[ , never mind, at least your reply is indicating to me that it isn't something simple that I am overlooking, so am hacking my way into now. Will post any solution I might come up with that might might be a starting point for your undoubtedly superior way.

Incidentally I am also not seeing how to make use of the download template - I see where both upload and download are rendered but not grasping without tracing how there can be a download widget without a directory to take files from?

Cheers
Andrew
0

#232 User is offline   Asgaroth 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 17-July 09
  • Location:Bogota, Colombia

Posted 10 October 2012 - 03:41 PM

the upload template is rendered as soon as you select the file. *before* uploading.
and the download template is used *after* the upload has happened allowing you to download, or delete, the files you just uploaded.
- Extension: Dynamic DataProvider Behavior
- Extension: XUpload - jQuery File Upload Extension
- Extension: PhpQuickProfiler - A Web Log Router that will help you profile your application
- Extension: XDateView - A Date grouped Grid View
- Extension: Foundation - An easy to use, powerful, and flexible framework for building prototypes and production code on any kind of device.



- Wiki: How to generate Yii like Documentation
- Wiki: How to re enable logging during unit testing
0

#233 User is offline   andrew1 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 09-May 12

Posted 10 October 2012 - 03:53 PM

That explains. Am part way thru using the demo indicated on your suggested previous link as a starting point. Will return to this later today.

Thanks heaps for your help.

Cheers
Andrew
0

#234 User is offline   soyoh 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 29-January 11

Posted 16 October 2012 - 09:12 AM

Hello,
and thanks for implement this jquery plugin to Yii.

im having some troubles, but when i upload an image, there are no "animations" (progressbar) or thumb generated, the file is uploaded ok, i mean, everything works ok, but no that, is this normal??

thank you, and sorry my bad english ..
0

#235 User is offline   Asgaroth 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 17-July 09
  • Location:Bogota, Colombia

Posted 16 October 2012 - 09:19 AM

View Postsoyoh, on 16 October 2012 - 09:12 AM, said:

Hello,
and thanks for implement this jquery plugin to Yii.

im having some troubles, but when i upload an image, there are no "animations" (progressbar) or thumb generated, the file is uploaded ok, i mean, everything works ok, but no that, is this normal??

thank you, and sorry my bad english ..


does the included demo works?
- Extension: Dynamic DataProvider Behavior
- Extension: XUpload - jQuery File Upload Extension
- Extension: PhpQuickProfiler - A Web Log Router that will help you profile your application
- Extension: XDateView - A Date grouped Grid View
- Extension: Foundation - An easy to use, powerful, and flexible framework for building prototypes and production code on any kind of device.



- Wiki: How to generate Yii like Documentation
- Wiki: How to re enable logging during unit testing
0

#236 User is offline   soyoh 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 29-January 11

Posted 16 October 2012 - 09:45 AM

View PostAsgaroth, on 16 October 2012 - 09:19 AM, said:

does the included demo works?


Forget this ... sorry. was my problem, outside files where not loaded because i'm working under SSL and temote files (tmpl.min.js) was being blocket.

thanks for your reply anyway!!

i'll make a fork and try to help.
0

#237 User is offline   Asgaroth 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 17-July 09
  • Location:Bogota, Colombia

Posted 16 October 2012 - 09:52 AM

View Postsoyoh, on 16 October 2012 - 09:45 AM, said:

Forget this ... sorry. was my problem, outside files where not loaded because i'm working under SSL and temote files (tmpl.min.js) was being blocket.

thanks for your reply anyway!!

i'll make a fork and try to help.


Great! any contribution is very welcome!
- Extension: Dynamic DataProvider Behavior
- Extension: XUpload - jQuery File Upload Extension
- Extension: PhpQuickProfiler - A Web Log Router that will help you profile your application
- Extension: XDateView - A Date grouped Grid View
- Extension: Foundation - An easy to use, powerful, and flexible framework for building prototypes and production code on any kind of device.



- Wiki: How to generate Yii like Documentation
- Wiki: How to re enable logging during unit testing
0

#238 User is offline   Amarnath Madanmohan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 09-October 12

Posted 19 October 2012 - 08:51 AM

Hi Asgaroth,

Thank you for this beautiful extension. I'm having an issue where after uploading the file the value is not getting updated in the DB field. I read as much post I found in this forum and exhausted. I really need your help as I have run out of all options.

My View file



<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'assessment-form',
'enableAjaxValidation'=>false,
));
echo $form->hiddenField($model,'File',array('size'=>60,'maxlength'=>255));
?>
<?php $this->endWidget(); ?>
<?php
$this->widget('xupload.XUpload', array(
'url' => Yii::app()->createUrl("site/upload"),
'model' => $xuploadform,
'attribute' => 'file',
'multiple' => true,
//'formView' => 'application.views.user._form',
'uploadTemplate' => '#template-upload',
'options' => array(
'sequentialUploads' => true,
'acceptFileTypes' => 'js:/(\.|\/)(CSV|ZIP)$/i',
'completed' => 'js:function (event, files, index, xhr, handler, callBack) {
$("#Assessment_File").val(\'\'+handler.response.name + \'\' );
}'
),
));
?>

<div class="Assessment">
<?php
echo $out1;
?>
</div>
============
My controller file is as per your documentation,


public function actions()
{
Yii::import("xupload.models.XUploadForm");
return array(
'upload'=>array(
'class'=>'xupload.actions.XUploadAction',
'path' =>Yii::app() -> getBasePath() . "/../uploads/",
'publicPath' => Yii::app() -> getBaseUrl() . "/uploads",
'subfolderVar'=>'parent_id',
),
);
}

public function actionIndex() {
$this->layout='column3';
Yii::import("xupload.models.XUploadForm");
$model = new Assessment();
$xuploadform = new XUploadForm;
$template = 'application.views.assessment.index';
$user = Yii::app()->user->name;
$_userData = User::model()->with('assessment')->find("username=?",array($user));
$criteria=new CDbCriteria;
$criteria = $criteria->compare('user_id',$_userData->id);
$dataProvider=new CActiveDataProvider('Assessment', array('criteria' => $criteria));
$out1 = $this->renderPartial($template, array('dataProvider' => $dataProvider),true);
#$this->render('adjacencyGrid',array('out1'=>$out1));
$this -> render('index', array('model' => $model, 'out1' => $out1, 'xuploadform' => $xuploadform));
}

===
It just uses another view to render data where first half is Xupload and rest is populated with Assessment model filtered data,

Assessment View:
--------------

<h1>Assessments</h1>

<?php

$this->widget('zii.widgets.jui.CJuiButton', array(
'name'=>'Data',
'caption'=>'Data',
'buttonType' => 'link',
//'url' => array('//JobsThroughPut/index'),
'id' => 'Data-id',
));

$this->widget('zii.widgets.jui.CJuiButton', array(
'name'=>'Reports',
'caption'=>'Reports',
'buttonType' => 'link',
//'url' => array('//JobsThroughPut/index'),
'id'=>'btn-link',
));

$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'assessment-grid',
'dataProvider'=>$dataProvider,
'columns'=>array(
'id' => array('name' => '', 'type'=> 'raw', 'value'=>'CHtml::checkBox("checkbox-id",$checked=false,array("id"=>$data->id, "class"=>"my-checkboxes"))'),
/* 'user_id', */
'fromid',
'cc',
'created_date',
'lastupdate',
'modeType',
'File',
'Status',
),
));
?>

<script type="text/javascript">
$(document).ready(function(){
$(".my-checkboxes").bind('click', function(){
var id = $(this).attr('id');

$("#btn-link").attr('href', '../jobsPerHour/getchart/ass_id/'+id);
$("#Data-id").attr('href', '../jobsPerHour/index/ass_id/'+id);
});
});
</script>

Please help me.

Regards,
Amar.
0

#239 User is offline   Asgaroth 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 371
  • Joined: 17-July 09
  • Location:Bogota, Colombia

Posted 19 October 2012 - 09:07 AM

View PostAmarnath Madanmohan, on 19 October 2012 - 08:51 AM, said:

Hi Asgaroth,

Thank you for this beautiful extension. I'm having an issue where after uploading the file the value is not getting updated in the DB field. I read as much post I found in this forum and exhausted. I really need your help as I have run out of all options.

My View file

...

Please help me.

Regards,
Amar.


I'll try to help you out, but please format your code because this way its really hard to read. use the "insert code snippet" in the post tools.
- Extension: Dynamic DataProvider Behavior
- Extension: XUpload - jQuery File Upload Extension
- Extension: PhpQuickProfiler - A Web Log Router that will help you profile your application
- Extension: XDateView - A Date grouped Grid View
- Extension: Foundation - An easy to use, powerful, and flexible framework for building prototypes and production code on any kind of device.



- Wiki: How to generate Yii like Documentation
- Wiki: How to re enable logging during unit testing
0

#240 User is offline   Amarnath Madanmohan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 09-October 12

Posted 19 October 2012 - 09:27 AM

Hi Asgaroth,

Thanks for your swift response. I've added the code snippet,

My site Index file:
-------------
<?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'assessment-form',
        'enableAjaxValidation'=>false,
));
 echo $form->hiddenField($model,'File',array('size'=>60,'maxlength'=>255));
?>
<?php $this->endWidget(); ?>
<?php
$this->widget('xupload.XUpload', array(
                    'url' => Yii::app()->createUrl("site/upload"),
                    'model' => $xuploadform,
                    'attribute' => 'file',
                    'multiple' => true,
                    //'formView' => 'application.views.user._form',
                    'uploadTemplate' => '#template-upload',
                    'options' => array(
                    'sequentialUploads' => true,
                    'acceptFileTypes' => 'js:/(\.|\/)(CSV|ZIP)$/i',
                    'completed' => 'js:function (event, files, index, xhr, handler, callBack) {
                        $("#Assessment_File").val(\'\'+handler.response.name + \'\' );
                        }'
                    ),
));
?>

<div class="Assessment">
<?php
echo $out1;
?>
</div>
~               


2. My Site controller:
------------------
        public function actions()
        {
                Yii::import("xupload.models.XUploadForm");
                return array(
                        'upload'=>array(
                        'class'=>'xupload.actions.XUploadAction',
                        'path' =>Yii::app() -> getBasePath() . "/../uploads/",
                        'publicPath' => Yii::app() -> getBaseUrl() . "/uploads",
                        'subfolderVar'=>'parent_id',
                        ),
                );
        }



3. It just uses another view to render data where first half is Xupload and rest is populated with Assessment model filtered data,

Assessment Index:
--------------

h1>Assessments</h1>

<?php

$this->widget('zii.widgets.jui.CJuiButton', array(
    'name'=>'Data',
    'caption'=>'Data',
    'buttonType' => 'link',
    //'url' => array('//JobsThroughPut/index'), 
    'id' => 'Data-id',
));

$this->widget('zii.widgets.jui.CJuiButton', array(
    'name'=>'Reports',
    'caption'=>'Reports',
    'buttonType' => 'link',
    //'url' => array('//JobsThroughPut/index'),
        'id'=>'btn-link',
));

$this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'assessment-grid',
        'dataProvider'=>$dataProvider,
        'columns'=>array(
               'id' => array('name' => '', 'type'=> 'raw', 'value'=>'CHtml::checkBox("checkbox-id",$checked=false,array("id"=>$data->id, "class"=>"my-checkboxes"))'),
        /*        'user_id', */
                'fromid',
                'cc',
                'created_date',
                'lastupdate',
                'modeType',
                'File',
                'Status',
        ),
));
?>

<script type="text/javascript">

$(document).ready(function(){
        $(".my-checkboxes").bind('click', function(){
                var id = $(this).attr('id'); 
                $("#btn-link").attr('href', '../jobsPerHour/getchart/ass_id/'+id); 
                $("#Data-id").attr('href', '../jobsPerHour/index/ass_id/'+id);
        });
});
</script>


Thanks again for all your help.

Regards,
Amar.
0

Share this topic:


  • (20 Pages)
  • +
  • « First
  • 10
  • 11
  • 12
  • 13
  • 14
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

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