duanpie2414
2014-04-10 05:09
浏览 103
已采纳

如何在Symfony 2中向提交的表单添加额外数据?

I have a simple form that only uploads an image. However, in my database I want to extract and record some EXIF data from that image.

I'm not sure what to use in Symfony2. It does't seem like the right place to calculate this extra information in the Entity. Where else could I put it?

<?php

namespace Timeline\DefaultBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\UploadedFile;

/**
 * @ORM\Entity
 * @ORM\HasLifecycleCallbacks
 */
class Document
{
    //...

    /**
     * @ORM\PrePersist()
     * @ORM\PreUpdate()
     */
    public function preUpload()
    {
        // extract EXIF here?
    }

}

图片转代码服务由CSDN问答提供 功能建议

我有一个只上传图片的简单表格。 但是,在我的数据库中,我想从该图像中提取并记录一些EXIF数据。 </ p>

我不确定在Symfony2中使用什么。 它似乎不是在实体中计算这些额外信息的正确位置。 我还能把它放在哪里?</ p>

 &lt;?php 
 
namespace Timeline \ DefaultBundle \ Entity; 
 
use Doctrine \ ORM \ Mapping as ORM; 
use Symfony  \ Component \ Validator \ Constraints as Assert; 
use Symfony \ Component \ HttpFoundation \ File \ UploadedFile; 
 
 / ** 
 * @ORM \ Entity 
 * @ORM \ HasLifecycleCallbacks 
 * / 
class Document \  n {
 // ....nnn / ** 
 * @ORM \ PrePersist()
 * @ORM \ PreUpdate()
 * / 
 n public function preUpload()
 {
  //在这里提取EXIF?
} 
 
} 
 </ </ code> </ pre> 
 </ div>

1条回答 默认 最新

相关推荐 更多相似问题