Welcome Guest, Not a member yet? Register   Sign In
MY_ classed and extending native libraries
#1

[eluser]sahanlak[/eluser]
Hello,

Because I'm having some issues with the Codeigniter upload class, I wanted to overwrite its is_allowed_filetype() function, I created a file called My_upload under application/libraries. But seems like it doesn't load properly, actually its not loading at all. I'm trying to extend the CI_Upload class, but for a test I created an empty class and echod something in __construct. At last I was able to load my class using auto load, I added my library name to autoload. So after I got it to load, I added my original code which extends the CI_Upload class. Now when I load my site, it says. Fatal error: Class 'CI_Upload' not found in......

I read the user guide and did as it say, but didn't work properly. Is there something that I have missed?

Thanks.
#2

[eluser]TaylorOtwell[/eluser]
Can you upload your MY_Upload class so we can take a look? Also, I assume it is in the application/libraries directory?
#3

[eluser]sahanlak[/eluser]
Yes its in application/libraries
#4

[eluser]TaylorOtwell[/eluser]
I got it to work in my CI installation by capitalizing the "U" in filename. The filename should be "MY_Upload.php".
#5

[eluser]sahanlak[/eluser]
Hmm yea, but it doesn't overwrite the function is_allowed_filetype(). Sad
#6

[eluser]Phil Sturgeon[/eluser]
MY_upload != MY_Upload
#7

[eluser]WanWizard[/eluser]
Unless you're on Windows, in which case MY_upload == MY_Upload... Wink
#8

[eluser]sahanlak[/eluser]
Thanks for the replies, the question I'm having right now is why does the sub class doesn't override the function 'is_allowed_filetype' in parent class :|
#9

[eluser]TaylorOtwell[/eluser]
I honestly don't know a ton about PHP's internal workings, but just off hand I notice the scope is not explicitly declared in your derived class, whereas the base class has the scope of is_allowed_filetype declared as "public". Does making your is_allowed_type method public make a difference?




Theme © iAndrew 2016 - Forum software by © MyBB