2015-04-28 21 views
0

我已調升sonatamediabundlePNG文件無法上傳奏鳴曲媒體捆綁

我可以上傳JPG文件雖然正確,當我嘗試上傳PNG文件。

它顯示錯誤。

An error has occurred during the creation of item "n/a". 

我的config.yml是這樣的。 我想我正確設置了png文件配置。 是否有任何其他檢查點上傳PNG?

sonata_media: 
    # if you don't use default namespace configuration 
    #class: 
    # media: MyVendor\MediaBundle\Entity\Media 
    # gallery: MyVendor\MediaBundle\Entity\Gallery 
    # gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia 
    default_context: default 
    db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr 
    contexts: 
     default: # the default context is mandatory 
      providers: 
       - sonata.media.provider.dailymotion 
       - sonata.media.provider.youtube 
       - sonata.media.provider.image 
       - sonata.media.provider.file 

      formats: 
       small: { width: 100 , quality: 70} 
       big: { width: 500 , quality: 70} 

    cdn: 
     server: 
      path: /myapp/web/uploads/media # Its not good I need to change depending on server... 

    filesystem: 
     local: 
      directory: %kernel.root_dir%/../web/uploads/media 
      create:  false 
    providers: 
     image: 
      service: sonata.media.provider.image 
      resizer: sonata.media.resizer.simple # sonata.media.resizer.square 
      filesystem: sonata.media.filesystem.local 
      cdn:  sonata.media.cdn.server 
      generator: sonata.media.generator.default 
      thumbnail: sonata.media.thumbnail.format 
      allowed_extensions: ['jpg', 'png', 'jpeg'] 
      allowed_mime_types: ['image/pjpeg', 'image/jpeg', 'image/png', 'image/x-png'] 
+0

從app/logs目錄中提供上述錯誤的日誌 –

+0

上傳函數的外觀如何? –

回答

1

你必須檢查你的表單:configureFormFields()

的錯誤是趕上有:

// show an error message if the form failed validation 
     if (!$isFormValid) { 
      if (!$this->isXmlHttpRequest()) { 
       $this->addFlash('sonata_flash_error', $this->admin->trans('flash_create_error', array('%name%' => $this->admin->toString($object)), 'SonataAdminBundle')); 
      } 
     } 
1

我有同樣的問題,但以JPG,但對我來說變成對於PHP的gd擴展未配置JPEG支持。

如果您想查看您的gd擴展支持哪種圖像格式,請檢查輸出gd_info();

我使用的碼頭工人,所以在Dockerfile我只好:

RUN apt-get install -y libpng-dev libjpeg-dev 

RUN docker-php-ext-configure gd --with-gd=shared \ --with-jpeg-dir=/usr/lib/x86_64-linux-gnu/

RUN docker-php-ext-install gd

但在本質上,AKE確保您有必要的庫安裝,這是libjpg-dev(或libpng-dev,取決於你遇到的問題),配置gd擴展名爲--with-jpeg-dir參數,指向安裝庫的文件夾(缺省值是上述docker命令中的缺省值),它應該可以工作。

相關問題