Yii Framework Forum: Extending CUploadedFile - Yii Framework Forum

Jump to content

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

Extending CUploadedFile Rate Topic: -----

#1 User is offline   Rolf 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 16-August 12

Posted 16 August 2012 - 09:38 AM

Hi,

Maybe you guys can help me out. I'm trying to extend CUploadedFile, but this is not possible. Because CUploadedFile returns itself, and not the class that overrides (in my case the saveAs function) the functions.
The reason i want to override this function is because i want to do some validation before uploading the file. And not validate in the controller where the class is called from.

Of course i've searched on the internet for possible solutions, but none were given. Perhaps you guys can help me.

Thanx!
0

#2 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 968
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 16 August 2012 - 11:47 PM

what type of validtion you need use the model validation YII has ;predefined validation rules for files as well
0

#3 User is offline   Rolf 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 16-August 12

Posted 17 August 2012 - 01:50 AM

Thanks for the reply! Only this is not quite what i'm looking for. The reason i want to extend CUploadedFile is because i want to do some validation before the file is uploaded, but after the file is validated by the file validator.
These checks consist of checking if the folder exists and if the file name is already uploaded.

Thanks again!
0

#4 User is offline   beezee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 18-December 12

Posted 29 January 2013 - 11:48 AM

View PostRolf, on 17 August 2012 - 01:50 AM, said:

Thanks for the reply! Only this is not quite what i'm looking for. The reason i want to extend CUploadedFile is because i want to do some validation before the file is uploaded, but after the file is validated by the file validator.
These checks consist of checking if the folder exists and if the file name is already uploaded.

Thanks again!


I had exactly the same issue, and my solution, though not as clean as simply extending, was to use a behavior. Almost as good and with a secondary class for the factory method it's seamless beyond the new method names.

Still can't post links, but I have an example of the implementation we used in a Github Gist - github . gist .com / 4665697
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