I have a product form that users can upload 5 pictures simultaneously. Everything is working fine with that but I’m trying to implement the sfThumbnail plugin so that it creates a thumbnail of each of the pictures at the same time. The code below works for Picture1 but Picture2, 3, 4, and 5 it doesn’t. I’ve tried messing with the code and I can’t get it to work with each file individually. It just takes the uploaded file for Picture2 for example and it names it the same as picture 1. So when it runs through I end up with 5 uploaded pictures, but only 1 thumbnail with the filename of the first picture.
I tried to duplicate the code 5 times and customize it for each of the pictures but I got the same result.
If there’s a more efficient way of doing this please show me. This is just what I got from the plugin documentation. Thanks
if($this->isModified())
{
$uploadDir = sfConfig::get('sf_upload_dir');
$thumbnail = new sfThumbnail(150, 150);
$thumbnail->loadFile($uploadDir.'/car/'.$this->getPicture1());
$thumbnail->save($uploadDir.'/car/thumbnail/'. $this->getPicture1());
}
This is what worked for me: