fuelphp / upload

FuelPHP Framework - File upload library
MIT License
26 stars 16 forks source link

config extension #9

Closed jhuriez closed 10 years ago

jhuriez commented 10 years ago

Hi,

When i upload image, i want to convert them all in "jpg" extension. So in the config array i have set 'extension' => 'jpg'.

But when i see in Upload\File class, you just replace the extension string in the filename. It's the real goal ? Or you just missed to convert the file with the extension mentionned in the config array ?

WanWizard commented 10 years ago

That is what you asked, isn't it? Change the extension to "jpg".

If you mean you want to change the mimetype, i.e. convert the uploaded file to a jpeg image, that is not the task of the upload Class, that is application code.

Validate the mime type of the uploaded file, save it (to a temporary location), and use an image package or the GD/ImageMagick tools to convert it.

jhuriez commented 10 years ago

Yes i thought Upload class changes the mimetype too. Thanks

WanWizard commented 10 years ago

Nope, it deals only with processing uploaded files. We like to keep different functionality separate.

What you can do is define a pre-save callback, that takes the file information, checks the mime type, and uses some image processing package to convert the file if needed, and update the mime type accordingly.