Demo ¶
jQuery file upload extension for Yii, allows your users to easily upload files to your server:
Setup instructions ¶
Add to your composer.json
{
"config": {
"vendor-dir": "protected/extensions/vendor"
},
"repositories": [
...
{
"type": "vcs",
"url": "https://github.com/Asgaroth/xupload.git"
}
],
"require": {
...
"Asgaroth/xupload": "v0.5.0"
}
}
Manually ¶
Download the files and extract them to you project desired folder
Configuration ¶
- Add an application alias in you application configuration that points to the extracted folder
...
'import'=>array(
'application.models.*',
'application.components.*',
),
'aliases' => array(
'xupload' => 'ext.vendor.Asgaroth.xupload'
'xupload' => 'ext.xupload'
),
- 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
- Create a controller to handle form based file uploads. Or use XUploadAction
- 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
- Override CController::actions() and register an action of class XUploadAction we (will use 'upload' for the examples), 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",
),
);
}
}
- 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, ));
}
Additional Documentation ¶
Here is a wiki describing a more complex workflow using this widget.
And a wiki explaining how to send additional data with your file
Note: See the attached project for more examples
Resources ¶
Changelog ¶
v0.5.0 Sat Nov 10 19:17:16 COT 2012
- Added $formClass to XUploadAction, to allow overwriting the default form class
- Improved location of thumbnail url handling
- Improved security
- Setup public variables to make using other form models / Active Record models easier.
- JavaScript-part of extension now properly depends on XUpload::$multiple parameter
- Added I18N support, added russian translation
- Fixed incorrect behavior when XUploadAction::$subfolderVar was false
- No script files are now loading from github.com/blueimp, all of them are locally available now
- Added XUpload::$showForm param - this allows easily avoid rendering
tag in widget view
v0.4.0 Mon Jul 2 16:25:53 COT 2012
- Added image preview assets
- Added image processing assets
- Added the ability to specify upload, download, and form views
v0.3a Sun Mon Apr 2 21:43:38 COT 2012
- Fixed missing dependencies
v0.3 Sun Apr 1 18:35:23 COT 2012
- Updated to the new jquery plugin version
v0.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
v0.1 Mon Mar 21 14:51:13 COT 2011
Colaborators ¶
License ¶
Released under the MIT license.
Total 20 comments
Pretty sure uploads are working fine on our system for IE 9 (haven't tested IE 10 yet)
It works for me in IE10. Does it work for anyone with IE9?
it doesn't work in IE at all! I was upset.
does the latest version work with IE 9+ ?
The extension is very good, more could update javascript and extension because it has several options, and the process method that resizes the image and between several. thanks
good and nice extension
Not that I know of, that line should't throw any error, please ask in the forum, and provide all relevant information.
Asgaroth, I think this is the only thing I need to fix with xupload before it is working perfectly.
I have enabled db session in the main.php with below code, then multiple files state is not maintaining. Code causing error : $userFiles = Yii::app()->user->getState($this->stateVariable, array());
so it is throwing error in firebug and not deleting all the files. Do I need to modify anything to use db sesssion?
i am able to bring up the extension, but when i add files the files are not showing up, any suggesstion, this one is also not saving in my upload folder.
Did you add in the upload action to your controller actions array? Probably worth starting there if you haven't. If you do, you should get some errors back from the server's Ajax response. If you need more help though, it's better to discuss on the forum.
The demo looks great, but it doesn't do a lot when I installed it.
I added the widget to my form as directed above and the buttons rendered on the page. I hit "Add files" which opened a file dialog, chose a file, and hit "Open".
The dialog closed and nothing else happened. No error messages, no network requests, nothing. Without an error message, it's a bit hard to debug - any ideas what's wrong, or at least a clue where I should look?
Great extension. thanks Asgaroth.
After start uploading , the photo is displaying in big size, any option to display it as in the preview? before clicking on start upload?
@drumaddict: if you can post your issue to the Github repo / add a pull request, would love to get those bugs fixed ...
I replaced assets with the newer version.Files get uploaded but the callback gives an error.Looked at the demo and now it seems that the plugin expects the json indexed by files,like so
After fixing that,the callback gave no error.Yet,the uploaded preview images are the full images by default.Still more editing to do,to make it work.
Not sure what the problem its, why does it says "xupload.url" in lowercase?
Please use the forum for this kind of questions
Property "xupload.url" is not defined.
_** My Code is:**_
hi go for extensions/actions/xuploadactions u ll find the controller and the destination..or u can edit the extensions/xupload/view/download .php and put ur target folder.the destination file is some what named uploads..if such a file does not exists in the application root folder www/testdrive/uploads create it.the file will be uploaded to that folder..
plz encourage me by likes or comment...i m a newbie to yii and these types of forums...
the image is not storing in to the database...it stores to some files that u can search in the application folder.sometimes named uploads or create that folder in the application root folder in the name->means www/testdrive/uploads
hi dears go to download.php there u can find the target file name...or go to xupload action there also u can change file name and target folder...if anyone got help by this like me or comment...i m new to yii and to this type of forums...
go to download.php inside extensions/view/download.php ---> there is an
please give height width parameters...
Leave a comment
Please login to leave your comment.