protected function storeAsZip(UploadedFile $file, array $data)
    {
        $disk = $this->storageDisk($data['disk']);

        // Make zip archive name with full path.
        $zipname = $disk->getDriver()->getAdapter()->getPathPrefix()
                  .$data['type'].DS.$data['category'].DS
                  .$data['name'].'.'.$data['extension'] . '.zip';

        // Check if new file exists
        if ($disk->exists($zipname)) {
            throw new FileException(sprintf(
                'File with name `%s` already exists!', $zipname
            ));
        }

        // Storing zip.
        $zip = new \ZipArchive;
        $zip->open($zipname, \ZipArchive::CREATE);
        $zip->addFile($file->getRealPath(), $data['name'].'.'.$data['extension']);
        $zip->close();

        $this->attributes['name'] = $data['name'].'.'.$data['extension'];
        $this->attributes['extension'] = 'zip';
        $this->attributes['filesize'] = filesize($zipname);
    }
protected function storeAsZip(UploadedFile $file, array $data)
    {
        $disk = $this->storageDisk($data['disk']);

        // Make zip archive name with full path.
        $zipname = $disk->getDriver()->getAdapter()->getPathPrefix()
                  .$data['type'].DS.$data['category'].DS
                  .$data['name'].'.'.$data['extension'] . '.zip';

        // Check if new file exists
        if ($disk->exists($zipname)) {
            throw new FileException(sprintf(
                'File with name `%s` already exists!', $zipname
            ));
        }

        // Storing zip.
        $zip = new \ZipArchive;
        $zip->open($zipname, \ZipArchive::CREATE);
        $zip->addFile($file->getRealPath(), $data['name'].'.'.$data['extension']);
        $zip->close();

        $this->attributes['name'] = $data['name'].'.'.$data['extension'];
        $this->attributes['extension'] = 'zip';
        $this->attributes['filesize'] = filesize($zipname);
    }
protected function storeAsZip ( UploadedFile $ file , array $ data ) { $ disk = $ this -> storageDisk ( $ data [ 'disk' ] ) ; // Make zip archive name with full path. $ zipname = $ disk -> getDriver ( ) -> getAdapter ( ) -> getPathPrefix ( ) . $ data [ 'type' ] . DS . $ data [ 'category' ] . DS . $ data [ 'name' ] . '.' . $ data [ 'extension' ] . '.zip' ; // Check if new file exists if ( $ disk -> exists ( $ zipname ) ) { throw new FileException ( sprintf ( 'File with name `%s` already exists!' , $ zipname ) ) ; } // Storing zip. $ zip = new \ ZipArchive ; $ zip -> open ( $ zipname , \ ZipArchive :: CREATE ) ; $ zip -> addFile ( $ file -> getRealPath ( ) , $ data [ 'name' ] . '.' . $ data [ 'extension' ] ) ; $ zip -> close ( ) ; $ this -> attributes [ 'name' ] = $ data [ 'name' ] . '.' . $ data [ 'extension' ] ; $ this -> attributes [ 'extension' ] = 'zip' ; $ this -> attributes [ 'filesize' ] = filesize ( $ zipname ) ; }
Manipulate whith archive file.
Manipulate whith archive file .