Php 我失去了一个变量。。。哪里
我有以下代码:Php 我失去了一个变量。。。哪里,php,Php,我有以下代码: <?php $id_sent = $_POST['id']; echo $id_sent; include ($_SERVER['DOCUMENT_ROOT']."/upload/upload_class.php"); $max_size = 1024*250*500; $my_upload = new file_upload; $my_upload->upload_dir
<?php
$id_sent = $_POST['id'];
echo $id_sent;
include ($_SERVER['DOCUMENT_ROOT']."/upload/upload_class.php");
$max_size = 1024*250*500;
$my_upload = new file_upload;
$my_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/uploads/";
$my_upload->extensions = array(".pdf");
$my_upload->max_length_filename= 50;
$my_upload->rename_file = true;
$my_upload->id_search = $id_sent;
if(isset($_POST['Submit'])) {
$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
$my_upload->the_file = $_FILES['upload']['name'];
$my_upload->http_error = $_FILES['upload']['error'];
if ($my_upload->upload()) {
mysql_query(sprintf("UPDATE psi_avize SET pdf = 'T' WHERE id = '%s'", $my_upload->id_search));?>
<table width="800" border="0">
<tr>
<th width="167" rowspan="2" scope="col"><img src="images/figure_check_mark_celebrate_anim_md_wm.png" width="129" height="142"></th>
<th width="471" height="29" scope="col"><div align="left">Succes!</div></th>
<th width="148" scope="col"> </th>
</tr>
<tr>
<td height="104"> </td>
<td> </td>
</tr>
</table><?php
echo $my_upload->show_error_string();
}
}
else {?> <strong>Insert file!</span></p>
</strong>
<table width="800" border="0">
<tr>
<th width="167" rowspan="2" scope="col"><img src="images/document.png" width="150" height="152"></th>
<th width="471" height="29" scope="col"><div align="left"></div></th>
<th width="148" scope="col"> </th>
</tr>
<tr>
<td height="104">Max = 5 MB.</td>
<td> </td>
</tr>
</table>
<p> </p>
Load file <form name="form1" action="<?php echo $_SERVER['PHP_SELF']; ?>"
enctype="multipart/form-data" method="post">
<div align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="11%" scope="col"> </th>
<th width="26%" scope="col"> </th>
<th width="51%" scope="col"><div align="left">
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max_size; ?>" />
<?php
echo $my_upload->create_file_field("upload", "Select file...", 25, false); ?></div></th>
<th width="12%" scope="col"> </th>
</tr>
<tr>
<td> </td>
<td> </td>
<td><div align="left">
<input name="Submit" type="submit" id="Submit" value="Upload" />
</div></td>
<td> </td>
</tr>
</table>
</div>
</form> <?php }
?>
看起来您遇到的问题是发送的$id\u
来自另一个页面的帖子。这就是您能够首先正确地回显它的原因
加载当前页面后,单击当前页面表单的提交按钮,上一页的POST
值将被此页面的POST
值覆盖
为了在该页面的帖子中保留该值,请将其存储在一个隐藏字段中,如下所示
<input type ='hidden' name='id' value='<? php echo $id_sent; ?>'>
你没有一个名为upload
的元素,但是只有一个输入类型file
@Fred ii-u错误$my\u upload->create\u file\u字段(…
,相反,他以文件插入的形式缺少id\u sent
。你应该从一个条件开始检查for是否已提交。比如..if(isset($\u REQUEST['id']))是的,当我回音(第三行)时,它是right@Fred-ii-是的,我的意思是;))捕捉得好,我认为这是由文件上传类处理的(op没有向我们展示),但我想这是correct@Steve:谢谢-是的,尽管这个问题似乎不清楚,但我认为这可能是OP面临的问题。