public function upload($id, array $files)
    {
        foreach ($files as $file) {
            if ($file instanceof FileEntity) {
                foreach ($this->dimensions as $index => $dimension) {

                    $width = (int) $dimension[0];
                    $height = (int) $dimension[1];

                    $destination = $this->makeDestination($id, $width, $height);

                    // Ensure that destination actually exists
                    if (!is_dir($destination)) {
                        mkdir($destination, 0777, true);
                    }

                    $to = sprintf('%s/%s', $destination, $file->getUniqueName());

                    $imageProcessor = new ImageProcessor($file->getTmpName());
                    $imageProcessor->thumb($width, $height);

                    // This might fail sometimes
                    $imageProcessor->save($to, $this->quality);
                }
            }
        }

        return true;
    }
public function upload($id, array $files)
    {
        foreach ($files as $file) {
            if ($file instanceof FileEntity) {
                foreach ($this->dimensions as $index => $dimension) {

                    $width = (int) $dimension[0];
                    $height = (int) $dimension[1];

                    $destination = $this->makeDestination($id, $width, $height);

                    // Ensure that destination actually exists
                    if (!is_dir($destination)) {
                        mkdir($destination, 0777, true);
                    }

                    $to = sprintf('%s/%s', $destination, $file->getUniqueName());

                    $imageProcessor = new ImageProcessor($file->getTmpName());
                    $imageProcessor->thumb($width, $height);

                    // This might fail sometimes
                    $imageProcessor->save($to, $this->quality);
                }
            }
        }

        return true;
    }
public function upload ( $ id , array $ files ) { foreach ( $ files as $ file ) { if ( $ file instanceof FileEntity ) { foreach ( $ this -> dimensions as $ index => $ dimension ) { $ width = ( int ) $ dimension [ 0 ] ; $ height = ( int ) $ dimension [ 1 ] ; $ destination = $ this -> makeDestination ( $ id , $ width , $ height ) ; // Ensure that destination actually exists if ( ! is_dir ( $ destination ) ) { mkdir ( $ destination , 0777 , true ) ; } $ to = sprintf ( '%s/%s' , $ destination , $ file -> getUniqueName ( ) ) ; $ imageProcessor = new ImageProcessor ( $ file -> getTmpName ( ) ) ; $ imageProcessor -> thumb ( $ width , $ height ) ; // This might fail sometimes $ imageProcessor -> save ( $ to , $ this -> quality ) ; } } } return true ; }
Upload images from the input

@param string $id Current id
@param array $files Array of file bags
@return boolean
Upload images from the input