How to change class.upload name?

See all posts Reply

How to change class.upload name? new!
by Marc, 16 years, 5 months ago
Well, looks like a stupid question.

I basically would like to use the class_upload within OsCommerce administration. Images manipulations are not exactly easy for unexperencied shop owner. Unfortunately, class with the same name (upload) already exists in OsC.

I was expecting to "simply" change the name of the class from 'upload' to 'imagesupload' but then upload without any useful debug information. Any help would be welcome.

I expect to post (with your permission) this addition as a OsCommerce contribution under a GPL license.

Thanks for this EXCELLENT work and spirit.Reply
Re: How to change class.upload name? new!
by Marc, 16 years, 5 months ago
Plz read "but then upload failed without any useful debug information"Reply
Re: How to change class.upload name? new!
by colin, 16 years, 5 months ago
You should be able to rename the class as you wish.

Let's say that the class is named My_OSC_Upload. You would then instantiate the class as following:
$handle = new My_OSC_Upload($_FILES['form_field']);
$handle->process();
echo $handle->log;

One thing thought, don't forget to also rename the constructor of the class if you change its name. So you have to change in two places:
class upload {
and
function upload($file, $lang = 'en_GB') {
becomes
class My_OSC_Upload {
and
function My_OSC_Upload($file, $lang = 'en_GB') {
Reply
Re: How to change class.upload name? new!
by Marc, 16 years, 5 months ago
Thx : I just forgot to rename the class constructor :S

Everything is solved now. Once again, thanks for the tip! I'll let you know about OSC contribution's development!Reply