1
votes

How can I upload a transparent PNG (and preserve this transparency) using Meioupload in CakePHP?

Thanks

1

1 Answers

3
votes

I'm having the same problem. This is what fixed it for me:

Around line 962 of MeioUploadBehaviour.php, there are 2 lines:

$imageArray = explode(".", $source);
$phpThumb->config_output_format = $imageArray[1];

Change the second line to:

$phpThumb->config_output_format = end($imageArray);

EXPLANATION: The original line is an attempt to set $phpThumb->config_output_format to the file extension of your uploaded image. It works, so long as there is only one '.' in the file path of your uploaded image. Eg., if your path is /mywebsite/images/myImage.png, then it gets 'png'.

But, if there's a '.' earlier in your $source, eg. /mywebsite.com/images/myImage.png then what you get returned is the middle part, from the first '.' to the second '.'

So you'd get something like: 'com/images/myImage'

Of course, 'com/images/myImage' isn't a valid config_output_format for phpThumb!

By making the change from $imageArray[1] to end($imageArray), you always get the last element of the image array, which should always be the file extension.

Really, this enhancement should be made permenantly in MeioUpload. EDIT: I've forked MeioUpload and made the fix. I've sent a pull request to jrbasso, but so far it hasn't been accepted. You can view my fork here: https://github.com/joshuapaling/MeioUpload