php - Symfony2 store docx file into database -


i'm trying store .docx file mysql database. know .docx files .zip file. however, i'm trying store them blob field, there should difference.

if try store file not .docx, .png, .jpeg, .pdf. works fine, when try store .docx file, 500 response, no error message.

this code:

public function saveresumee($slug, $file)   {     $em = $this->getentitymanager();      $resumee = new file(file_get_contents($file), $file->getmimetype(), $file->guessextension(), $file->getclientsize());     $em->persist($resumee);     $em->flush(); // blows here!     ...      return true;   } 

here file entity

<?php  namespace dnd\rahapibundle\entity;  use doctrine\orm\mapping orm;  /**  * file  *  * @orm\table()  * @orm\entity  */ class file {    public function __construct($data, $type, $extension, $length)   {      $this->data = $data;     $this->type = $type;     $this->extension = $extension;      if ($length) $this->length = $length;   }    /**    * @var integer    *    * @orm\column(name="id", type="integer")    * @orm\id    * @orm\generatedvalue(strategy="auto")    */   private $id;    /**    * @var string    *    * @orm\column(name="data", type="blob")    */   private $data;    /**    * @var string    *    * @orm\column(name="extension", type="string", length=255)    */   private $extension;    /**    * @var integer    *    * @orm\column(name="length", type="integer")    */   private $length;    /**    * @var string    *    * @orm\column(name="type", type="string", length=16)    */   private $type;     /**    * id    *    * @return integer    */   public function getid()   {     return $this->id;   }    /**    * set data    *    * @param string $data    * @return file    */   public function setdata($data)   {     $this->data = $data;      return $this;   }    /**    * data    *    * @return string    */   public function getdata()   {     return $this->data;   }    /**    * set length    *    * @param integer $length    * @return file    */   public function setlength($length)   {     $this->length = $length;      return $this;   }    /**    * length    *    * @return integer    */   public function getlength()   {     return $this->length;   }    /**    * set type    *    * @param string $type    * @return file    */   public function settype($type)   {     $this->type = $type;      return $this;   }    /**    * type    *    * @return string    */   public function gettype()   {     return $this->type;   }    /**    * @return string    */   public function getextension()   {     return $this->extension;   }    /**    * @param string $extension    */   public function setextension($extension)   {     $this->extension = $extension;   } } 

what wrong this?

ok, got work.

as @sdespont mentioned above, length problem, mime type of .docx file extremely large, updated field this:

  /**    * @var string    *    * @orm\column(name="type", type="string", length=16)    */   private $type; 

to this:

  /**    * @var string    *    * @orm\column(name="type", type="string", length=255)    */   private $type; 

Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -