【发布时间】:2017-07-17 12:33:36
【问题描述】:
我有这个应该上传文件的 api。该代码旨在在$request->files 中查找应在何处上传的文件,但该变量为空。相反,我在$content 中以字符形式(����)找到图像。这种行为是错误的还是我错过了什么?
我检查了composer.json,但没有包含或配置上传(Vich 或 DoctrineExtensions)包。我可以设置其中一个,但我不知道当前的行为是天生错误的,还是以前的开发人员比我更了解这一点?
作为记录,我有 File 类的 yaml 文件,它看起来类似于来自 DoctrineExtensions - Uploadable 的文件
MyApp\FileBundle\Entity\File:
type: entity
table: file_records
repositoryClass: MyApp\FileBundle\Repository\FileRepository
id:
id:
type: integer
generator:
strategy: AUTO
fields:
path:
name: path
type: string
name:
name: string
type: string
mimeType:
name: mimeType
type: string
nullable: true
size:
name: size
type: decimal
nullable: true
initialName:
name: initial_name
type: string
Ps:文件应该保存为文件,而不是数据库中的 blob。
【问题讨论】:
标签: php symfony file-upload doctrine symfony-3.2