如果验证码失败,PHP 表单会保留有关文件上传的输入
我想知道如果发生验证码或无效输入,如何保留以 php 形式上传照片时输入的信息。所有其他字段都保留其输入,但上传路径除外,即人员输入“C:\Users\inc\Desktop\3.png”,如果在表单提交期间发生任何一种情况,路径就会丢失(...php5#error
<div class="photo">
<li class='field_block' id='field_35_div'>
<div class='col_label'>
<label class='form_field'>Photo 1</label>
<label class='form_required' > </label>
</div>
<div class='col_field'>
<input type="file" name="field_35" id="field_35" value="" class='text_box1' onchange="fmgHandler.check_upload(this);">
<div id='field_35_tip' class='instruction'></div>
</div>
)尝试添加回显,但这不起作用。
I would to know how to retain information entered for photo upload in php form if either captcha or invalid entry occurs. All other fields retain their input, with the exception of upload path, i.e. person enters "C:\Users\inc\Desktop\3.png" and path is lost if either occurs during form submission (...php5#error)
<div class="photo">
<li class='field_block' id='field_35_div'>
<div class='col_label'>
<label class='form_field'>Photo 1</label>
<label class='form_required' > </label>
</div>
<div class='col_field'>
<input type="file" name="field_35" id="field_35" value="" class='text_box1' onchange="fmgHandler.check_upload(this);">
<div id='field_35_tip' class='instruction'></div>
</div>
I tried adding echo, but this does not work.
文件字段无法预先填充。而且您可能不希望用户每次都必须一次又一次地上传文件,因为这可能需要很长时间。
将文件保存在服务器上的某个位置,并在会话中或隐藏的输入字段中记住它是哪个文件。在文件选择器旁边显示类似“文件已上传”的内容。如果用户选择上传另一个文件,则覆盖之前上传的文件,否则使用之前上传的文件。
File fields cannot be pre-populated. And you probably don't want the user to have to upload the file every time again and again anyway, as that may potentially take a long time.
Save the file somewhere on your server and remember either in the session or in a hidden input field which file it was. Display something like "file uploaded" next to the file selector. If the user choses to upload another file, overwrite the previously uploaded file, otherwise use the previously uploaded file.