Yii Framework Forum: CUploadedFile - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

CUploadedFile Rate Topic: -----

#1 User is offline   zekus 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 09-March 10
  • Location:London

Posted 24 June 2011 - 04:12 AM

Hi,

I was trying to extend the CUploadedFile component to add more saveAs methods and allow to use different storages (like s3) but, because it is using a singleton (CUploadedFile::getInstance()) to instanciate the object, it looks impossible.

Unless I'm doing something wrong here, can we make this component more flexible?
0

#2 User is offline   callmez 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 04-April 12

Posted 09 May 2012 - 09:47 AM

I also had this problem! i want this component can do more things
0

#3 User is offline   alexvasilchenko 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 08-May 12

Posted 06 August 2012 - 11:05 AM

Hi!
In my project I had to create my own version of this class (in terms to make hierarchy Uploaded File -> Uploaded Video, Uploaded Image etc), where i created instance i got current class in following way:
$class = get_called_class();
static::$_files[$key] = new $class($names, $tmp_names, $types, $sizes, $errors);


Also to use static:: instead self::

And i found it's useful to create beforeSave and afterSave methods.

Also I made wrappers for move_uploaded_file and is_uploaded_file cause I needed to mock them for functional tests.

Actually it would be good to make it possible to have multiple uploader classes that can be changed in config to upload to local server filesystem or Amazon S3 or whatever.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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