我正在努力在我的网站上上传.pdf文件.
我创建了一个实体,其中包含字符串中文件的名称.有实体映射:
<field name="pdf" type="string" column="pdf" length="200" nullable="true"/>
Run Code Online (Sandbox Code Playgroud)
我输入文件的表单:
$builder
->add('pdf', FileType::class, array('label' => 'Fiche de paie'))
/* other input */
;
Run Code Online (Sandbox Code Playgroud)
我的表格观点:
{{ form_start(form) }}
{{ form_row(form._token) }}
<div class="modal-body row">
<div class="col-md-6 col-sm-8">
/* other input */
{{ form_row(form.pdf) }}}
</div>
<div class="col-md-6 col-sm-8">
/* other input */
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info" id="save">{% trans %}Save{% endtrans %}</button>
</div>
{{ form_end(form, { 'render_rest': false } ) }}
Run Code Online (Sandbox Code Playgroud)
还有控制器:
if ($form->isSubmitted() && $form->isValid()) {
$pdf = …Run Code Online (Sandbox Code Playgroud)