Yii 1.1: pupload

Plupload Widget - upload files using HTML5 Gears, Silverlight, Flash, BrowserPlus or normal forms.
18 followers

Yii widget wrapper for Plupload: http://www.plupload.com/ Allows you to upload files using HTML5 Gears, Silverlight, Flash, BrowserPlus or normal forms, providing some unique features such as upload progress, image resizing and chunked uploads.

Documentation

Requirements

  • Yii 1.1 or above

Installation

  • Extract the release file under protected/extensions

Usage

See the following code example:

$this->widget('application.extensions.Plupload.PluploadWidget', array(
   'config' => array(
       'runtimes' => 'flash',
       'url' => '/image/upload/',
   ),
   'id' => 'uploader'
));

Change Log

  • no updates coming for this widget (see comments)
  • go here instead: https://github.com/enricodetoma/yii-plupload

February 13, 2010

  • Initial release.

Total 13 comments

#17397 report it
Trejder at 2014/06/03 08:09am
@woody1ks

Have you compared your code with the original one? 112 lines (your widget) versus 238 lines (original one). You have chopped-off half of the code, without giving even a tiny explanation, why?

Removing over 50% of the code, including some key functionality (callback for a good start) you call an update? Any reason or explanation, why you did that?

#13539 report it
woody1ks at 2013/06/04 09:19pm
Recently upgraded this for a project needing IE7 uploads

Just so no one else has to go through the pain I just had to go through. I hope this helps someone.

https://github.com/woody1ks/Plupload.git

Update Comments:

  • upgraded to latest Plupload v1.5.7

  • Added preferred support for HTML5

  • removed redundant gears code thanks to browser plus

  • Added yii model support

  • Added HTML Attributes support.

<?php 
$this->widget('application.extensions.Plupload.PluploadWidget', array(
   'config' => array(
       'runtimes' => 'flash',
       'url' => '/image/upload/',
   ),
   'model'=>$model,
   'attribute'=>'files',
   'id' => 'uploader',
   'htmlAttributes'=> array(
       'class' => 'myUploaderClass',
   ),
)); 
?>
#3791 report it
streetdaddy at 2011/05/08 09:30am
Uploading docx, pptx, xslx, etc

I have plupload configuration as follows:

'filters' => array(
    array(
        'title' => Yii::t('app', 'Activity documents'),
        'extensions' => 'jpg,jpeg,gif,png,doc,docx,xls,xlsx,ppt,pptx,pdf,rtf'
    ),
),

however, on Chrome OSX all the .x file types cannot be selected by the user to be uploaded, ie docx, pptx, xslx...

has anyone experienced this issue and found a solution?

#3554 report it
gazbond at 2011/04/19 01:47am
@streetdaddy

This widget never really worked out for me - server side not really compatible with what I wanted. I suggest using an Uploadify widget instead. Its flash only but then again HTML5 etc. browser support is poor.

#3551 report it
streetdaddy at 2011/04/18 07:26pm
Users saving model before files have finished uploading

I have reports from users that file uploads are 'not working', however I suspect that they're clicking 'Save' before the uploads have completed because it is not obvious to them that it hasn't completed... Yes, users can be a bit stupid sometimes!

However, it does strike me as a usability issue...

is there anyway I can disable the 'Save' or 'Create' button on a model form until all uploads have completed? I have tried the callback option, but this is fired after each upload completes, so doesn't solve the problem for multiple uploads...

Thanks in advance for any suggestions.

#2809 report it
drumaddict at 2011/02/13 02:37am
@enrico.detoma Problems with controller action,jqueryUI does not work

Hi,great extension.I got it to work after I tweaked a little bit your controller action on github.There is a line

unlink($_FILES['file']['tmp_name']);

that will basically stop script execution without a @ at the beginning. Also the block

if (isset($_SERVER['HTTP_CONTENT_DISPOSITION'])) {
                  $arr = array();
                  preg_match('@^attachment; filename="([^"]+)"@',$_SERVER['HTTP_CONTENT_DISPOSITION'],$arr);
                  if (isset($arr[1]))
                      $originalname = $arr[1];
              }

never gets executed so the original name gets lost.I had to add

$original_name=  $_FILES['file']['name'];

to store the original name. To move the uploaded files out of the temp directory I added

$temppath=$targetDir . DIRECTORY_SEPARATOR . $fileName;
              $app_root=substr( Yii::app()->baseUrl, 1, strlen(Yii::app()->baseUrl)-1);
              $dest= $_SERVER['DOCUMENT_ROOT'].DIRECTORY_SEPARATOR .
              $app_root.DIRECTORY_SEPARATOR.
              'assets'.DIRECTORY_SEPARATOR.
              'uploads'.DIRECTORY_SEPARATOR.                                                                                                                                                                          
              'pl'. DIRECTORY_SEPARATOR .                                                                   
               $original_name;
 
            rename($temppath ,$dest);

Unfortunately,the jqueryUI option does not work for me.When set to true the widget appears 'naked' without table structure.The buttons still work but there is no layout.This is my widget configuration,any help is welcome.I am in windows.

$this->widget('application.widgets.plupload.PluploadWidget', array(
         'config' => array(
            'runtimes' => 'gears,flash,silverlight,browserplus,html5',
            'url' => $this->createUrl('/pl/upload/'),
             //'max_file_size' => str_replace("M", "mb", ini_get('upload_max_filesize')),
            // 'max_file_size' => Yii::app()->params['maxFileSize'],
               'max_file_size' =>  '1mb',
             'chunk_size' => '1mb',
             'unique_names' => true,
             'filters' => array(
              array('title' => Yii::t('app', 'Images files'), 'extensions' =>'jpg,jpeg,gif,png'),   
              ),
             'language' => Yii::app()->language,
             'max_file_number' => 10,
             'autostart' => false,
             'jquery_ui' => true,
             'reset_after_upload' => true,
         ),
         'callbacks' => array(
             'FileUploaded' => 'function(up,file,response){console.log(response.response);}',
        ),
         'id' => 'uploader'
      ));
#2474 report it
enrico.detoma at 2011/01/06 05:41pm
Updated version

I've finally put my updated version of this extension on GitHub: https://github.com/enricodetoma/yii-plupload

#63 report it
leonhart135 at 2010/09/27 07:33pm
cant get file from drop.io

hi,

the pupload is great but i can't get the file update from http://drop.io/8nyaity/asset/plupload-zip , the file is protected and need password to access it. Could you please share the guest password, i really need the update. Thanks.

#322 report it
tuga at 2010/07/09 11:22am
Custom Layout

I think you did a good job wrapping this script, but I also have the same problems with DIRECTORY_SEPARATOR.

Another thing is that like that you cannot change the layout to a custom uploader, so what you can do is add a property called custom, and then if it was set you could change the run method to what the custom was. Like that one can make their custom uploader and maybe use a renderPartial(that's what I did on my code).

Thanks for your work

#678 report it
gazbond at 2010/03/21 04:15pm
Not so great

Uploadify is better, but flash only.

#753 report it
YorkSEO at 2010/03/05 04:55am
Watch out for the licence

A decent widget and plupload works really well, however it's GPL, so you'll have to open source all of your web app if you want to use it

#780 report it
Spyros at 2010/03/01 03:47am
url attribute

The url attribute is not the path where files will be uploaded but an url for the script that will handle the upload. Also I can't find a way to get the uploaded files. There's not in $_FILES, $_POST or anywhere else

#803 report it
notzippy at 2010/02/26 03:43pm
Small issues on windows

A lot of the URL paths use the "DIRECTORY_SEPARATOR", this caused some issues on windows. Changing this to "/" and things worked much better..

Leave a comment

Please to leave your comment.

Create extension
Downloads
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: gazbond
  • Category: User Interface
  • Votes: +10 / -6
  • Downloaded: 3,155 times
  • Created on: Feb 13, 2010
  • Last updated: Apr 19, 2011