简体   繁体   English

无法在提交的页面上回显文件输入字段..?

[英]can't echo file input field on submitted page..?

i have an extremely large form that is being submitted to an 'update' page which runs some SQL queries and updates the fields and then redirects back to the original page. 我有一个非常大的表单,正在提交给“更新”页面,该页面运行一些SQL查询并更新字段,然后重定向回原始页面。 everything has been working properly. 一切都正常工作。 I'm using $_POST to send my variables to the update page. 我正在使用$_POST将变量发送到更新页面。

i recently needed to add a <input type='file' /> field to the page. 我最近需要在页面上添加<input type='file' />字段。 Whenever the user selects a file, the form breaks, and nothing is getting submitted to the next page. 每当用户选择文件时,表格就会中断,并且没有任何内容提交到下一页。

I tried echoing my $_POST variables on the update page. 我尝试在更新页面上回显$_POST变量。 They come through perfectly as long as the file field isn't set. 只要未设置file字段,它们就可以完美通过。 If I choose a file, then none of the variables come though. 如果我选择一个文件,那么所有变量都不会出现。

i'm really stumped as to why this is happening. 我真的很困惑为什么会这样。 does anyone have any ideas why. 没有人有任何想法为什么。 here is an excerpt. 这是摘录。

An excerpt of the huge form: 巨大形式的摘录:

<form enctype="multipart/form-data" method="post"  action="editConfirm.php">
      .
      .
     <input type="file" name="new_file" id="new_file"  />                                           
     <input type='field' width='25px' name='fakeInput' id='fakeInput' value='' />
     <input type="hidden" name="compressed_file_id" id="compressed_file_id"   value='<? echo $compressedID; ?>' />

And the confirmation page: 和确认页面:

echo "New File = ".$_POST['new_file'];
echo "<br />Master Title = ".$_POST['masterTitle'];
echo "<br />Compressed File ID = ".$_POST['compressed_file_id'];

So those all echo properly as long as New File isn't set. 因此,只要未设置“新文件”,所有这些文件都会正确响应。 If I select a file and submit the form, they all break and nothing comes through. 如果我选择一个文件并提交表格,则它们都将损坏,并且没有任何结果。

You wil not get uploaded file array as $_POST. 您不会以$ _POST的形式获取上传的文件数组。 You have to use $_FILES["new_file"] to get file properties array 您必须使用$ _FILES [“ new_file”]来获取文件属性数组

Reference http://php.net/manual/en/reserved.variables.files.php 参考http://php.net/manual/en/reserved.variables.files.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM