1

我试图让 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>
4

3 回答 3

1

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

所以检查$form->configure(array( "enctype" => "multipart/form-data" ));你的代码中的行。

于 2013-02-01T22:14:47.580 回答
0
<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

于 2013-02-01T22:14:57.233 回答
0

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

于 2013-02-01T22:30:43.270 回答