未上载 php-form-builder-class 文件


php-form-builder-class files not being uploaded

我正在尝试让 File 元素在 pfbc 中工作,但我没有得到任何其他内容,除了 $_POST['AvatarLrg'] 中的文件名,$_FILES为空。有没有人有我可以仔细阅读的工作示例?

在顶部:

<?php
$form = new Form('trucking_edit');
$form->configure(array( "enctype" => "multipart/form-data" ));
$form->addElement(new Element_File("Profile Avatar:", "AvatarLrg"));
$form->addElement(new Element_Button);
?>

而在身体里:

<?php $form->render(); ?>

表单显示正常,所有其他元素显示并正常工作,只有文件:/任何帮助表示赞赏。

编辑:生成的 HTML:

<form method="POST" id="edit_profile" action="profile.php?pid=16&edit=save" name="tf_profileedit">
...
<div class="control-group">
   <label class="control-label" for="trucking_edit-element-3">Profile Avatar:</label>
   <div class="controls">
      <input type="file" name="AvatarLrg" id="trucking_edit-element-3"/>
   </div>
</div>
...
</form>

我从未使用过该类,但错误的原因是表单标签中缺少 enctype 属性。

因此,请检查代码中的$form->configure(array( "enctype" => "multipart/form-data" ));行。

<form method="POST" enctype='multipart/form-data' id="edit_profile" action="profile.php?pid=16&edit=save" name="tf_profileedit">
...
<div class="control-group">
   <label class="control-label" for="trucking_edit-element-3">Profile Avatar:</label>
   <div class="controls">
      <input type="file" name="AvatarLrg" id="trucking_edit-element-3"/>
   </div>
</div>
...
</form>

你忘了输入

我发现了问题;页面上的另一个表单干扰了它(由于旧代码,它们重叠了)。我删除了另一个表单,它可以工作。我还可以删除 enctype 行,因为当您添加文件元素时,PBFC 会自动更改 enctype。谢谢你们的帮助。