xupload

jquery file upload extension for yii
85 followers

Announcement!!!

This extension has been updated to use the V5 of the jquery plugin

Demo

jQuery file upload extension for Yii, allows your users to easily upload files to your server:

Setup instructions

  1. Download the files and extract them to you project desired folder
  2. Add an application alias in you application configuration that points to the extracted folder
...
'import'=>array(
    'application.models.*',
    'application.components.*',
),
'aliases' => array(
    //assuming you extracted the files to the extensions folder
    'xupload' => 'ext.xupload'
),
 
'modules'=>array(...
  1. Create a model, declare an attribute to store the uploaded file data, and declare the attribute to be validated by the 'file' validator. Or use XUploadForm
  2. Create a controller to handle form based file uploads. Or use XUploadAction
  3. Add the Widget to you view
<?php
$this->widget('xupload.XUpload', array(
                    'url' => Yii::app()->createUrl("site/upload"),
                    'model' => $model,
                    'attribute' => 'file',
                    'multiple' => true,
));
?>

Info: Ensure that the apache server has write permissions in the folder you are uploading the files, XUpload will try to create the upload folder if it doesn't exist already.

Using XUploadAction and XUploadForm:

  • XUploadAcion adds basic upload functionality to any controller.
  • XUploadForm its a simple form model to store uploaded file data
  1. Override CController::actions() and register an action of class XUploadAction with ID 'upload', and configure its properties:
class SiteController extends CController
{
    public function actions()
    {
        return array(
            'upload'=>array(
                'class'=>'xupload.actions.XUploadAction',
                'path' =>Yii::app() -> getBasePath() . "/../uploads",
                'publicPath' => Yii::app() -> getBaseUrl() . "/uploads",
            ),
        );
    }
}
  1. Create an initial action that will render the form using the XUploadModel:
public function actionIndex() {
        Yii::import("xupload.models.XUploadForm");
        $model = new XUploadForm;
        $this -> render('index', array('model' => $model, ));
    }

Note: See the attached project for more examples

Resources

Changelog

V 0.3a Sun Mon Apr 2 21:43:38 COT 2012

  • Fixed missing dependencies

V 0.3 Sun Apr 1 18:35:23 COT 2012

  • Updated to the new jquery plugin version

V 0.2 Sun May 8 19:28:43 COT 2011

  • Added Multiple file uploading functionality
  • Integrated XUploadAction with a few changes (thanks to tydeas_dr)
  • Moved XUploadForm to the extension folder

v 0.1 Mon Mar 21 14:51:13 COT 2011

  • First release

License

Released under the MIT license.

Total 20 comments

#7843 report it
Asgaroth at 2012/04/22 01:36pm
@yiqing95

You can always create your own upload action, XUploadAction is just basic upload functionality.

Please use the forums for support.

And please try not to yell at me :)

#7830 report it
yiqing95 at 2012/04/21 01:44am
destination file name ?

what 's the destination file name . how can i get it ?

there is not a way to get dest file path ! unless you expose it as a XUploadAction's public variable . we often save it to database .

you should give this permission to us , but as your manners .

#7811 report it
Asgaroth at 2012/04/19 10:31am
@jzhong5

Styles are given by bootstrap CSS, styling is out of the scope of the extension, you can style the widgets any way you like, if you want the same styles as the demo check this post

#7793 report it
jzhong5 at 2012/04/18 10:42pm
lost css

It works fine in the demo. But each time I put it in my project. no css will appear.... any ideas?

#7664 report it
Asgaroth at 2012/04/06 10:54am
@yiidf

Thanks for your words, they are very much appreciated, but please use the forum for support.

The reason the thumbs are not working in this demo, its because I didn't include the required files/logic, if you want to have thumbs, take a look at How to use image resizing functionality with the basic plugin

#7662 report it
yiidf at 2012/04/06 06:46am
thumbs not displayed

First of all... great extension! Many thanks for that. If it wasn't for this extension I wouldn't even know about this great jQuery plugin. Unfortunately, I have a minor problem with the thumbs that are not displayed when using this demo/plugin; however when using the original jQuery demo the result is slightly different...

Mac/Safari:
jQuery demo: after drop: thumbs no
jQuery demo: after upload: thumbs ok
vs
this demo: after drop: thumbs no
this demo: after upload: thumbs no

Mac/Firefox:
jQuery demo: after drop: thumbs ok
jQuery demo: after upload: thumbs ok
vs
this demo: after drop: thumbs ok
this demo: after upload: thumbs no

It doesn't seem to be a path issue because the images are uploaded properly and the link to the full-size image is working, too; only the thumbs won't show. Is this a matter of platform/browser or jQuery version (using 1.7.1)? Or am I missing something else?

Thanks for help.

#7608 report it
laupkram at 2012/04/03 01:24am
Donwloading index.php in IE 8 and lower

when I'm using your uploader in Internet Explorer 8 and lower the uploader opens my download dialog downloading the index.php

#7598 report it
Asgaroth at 2012/04/02 09:52am
@laupkram

It is not backwards compatible. the jquery plugin changed a lot.

#7596 report it
laupkram at 2012/04/02 04:10am
Overwriting

I have the 0.2 version of your uploader is it ok if I overwrite the old XUploadAction with the new one?

#7329 report it
Asgaroth at 2012/03/14 10:36am
@riyas

try http://www.yiiframework.com/forum/index.php/topic/21284-xupload-update/page__view__findpost__p__143349

#7323 report it
riyas at 2012/03/14 07:55am
xupload inside Cjuidialog widget

is that possible to use this widget inside a Cjuidialog widget

#6870 report it
DarkNSF at 2012/02/09 09:01pm
Breaks jQuery ui and Callbacks don't work

also..

list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id=$this->htmlOptions['id']; } else { $this->htmlOptions['id']=$id; }

#6578 report it
Asgaroth at 2012/01/19 09:41am
@afnan

Hi afnan,

I'm sorry that no one replied to your post.

I order to receive better support, you may post to the extension forum thread, which I will receive a notification for. I don't log into the forums often. so I didn't know about your random thread.

If you are having trouble with the demo, It might be your local configuration, as the demo was tested before being uploaded, and no one else has mention issues with it before.

I would also recommend, to investigate a little more, before posting a question. in the resources section of this extension, there is a Wiki that answers many common questions, and has several examples, including one to yours.

#6574 report it
tydeas_dr at 2012/01/19 08:52am
@afnan
hi there This extension is great as people say but I am extremely frustrated by no help at forums over stackoverflow and Yii forums.

This has nothing to do with the current extension. Its normal that many people over stackoverflow and forum have no experience with the current extensions. I can not understand why you mention this at all

Also I may be wrong but documentation is poor it should be detailed.

The extension is open source and you contribute to it by giving a more details documentation. So go and do it.

I posted question and waited for whole 1 day and still no answer

Why do you thing this is related to the extension?

#6573 report it
afnan at 2012/01/19 08:03am
Issues with upload

hi there This extension is great as people say but I am extremely frustrated by no help at forums over stackoverflow and Yii forums. Also I may be wrong but documentation is poor it should be detailed.

Secondly you would say try demo out ......And demo does not work either it does not uploads files just shows progress bar for 1-2 seconds and then vanishes.

I posted question and waited for whole 1 day and still no answer

http://www.yiiframework.com/forum/index.php?/topic/27918-upload-image-with-image-title/

#6482 report it
riazqadeer at 2012/01/13 01:12am
Upload Multiple files

Bundle of thanks for providing that extensions, thanks again and again

#5639 report it
RomanSolomatin at 2011/10/27 10:40pm
Thanks

Thanks a lot for this extension!

#5277 report it
russellfeeed at 2011/09/29 11:57am
Returning and displaying errors.

In my LoadController/uploda action, I'm opening the file which has been uploaded and doing some validation on the actual contents of the file.

If I find errors, how do I send show those errors to the user?

Thanks Russell

#4412 report it
Asgaroth at 2011/07/06 12:41pm
@quarkmarino

The wiki for the original jquery plugin has been restored

https://github.com/blueimp/jQuery-File-Upload/wiki

You can find the answer to your specific need here

#4308 report it
quarkmarino at 2011/06/23 12:56pm
Multiple instances

Hi, great module, thanks, but how do I manage multiple instances, I've just created 2 juidialog and load an xupload extencion on each one from diferent views, but when a add i file to the second xupload widget it is queued to the first xupload widget, so how do I add files to each one separately, thank you, and great extension.

Leave a comment

Please to leave your comment.

Create extension