表单到iframe提交 - 文件上传后如何重置表单


Form to iframe submission - how do you reset the form after file upload?

我有一个将结果提交到 iframe 的表单。提交的字段和文件上传由 upload.php 处理。一切都按预期工作,创建 ajax 样式的结果,尽管我希望表单在成功提交文件后重置。否则,提交按钮将继续上传相同的文件。

形式

<form action="functions/upload.php" method="POST" enctype="multipart/form-data" name="form1" id="form1" target="fileupload">

内嵌框架

<iframe name="fileupload" frameborder="0" src="functions/upload.php" style="float:none; color:#FFF; display:none" width="100%" id="result" allowtransparency="true"></iframe> 

您可以在成功上传文件后立即在iframe内运行以下 JavaScript 代码。

parent.document.getElementById("form1").reset();