***** 简短中的错误是什么: - >>>
我一次上传多个图片文件,为此我使用POST方法将FILES发布到uploader.php 为了我的测试目的我试图只上传第一个文件(即“分配”)。 现在 当我选择一个文件并单击提交我的uploader.php时没有得到发布的“分配”。它显示错误“未定义的索引:第11行的C:\ wamp \ www \ Pagination_test \ uploder.php中的分配”
allotment letter :
<form enctype="multipart/form-data" action="uploder.php" method="POST" >
<input type="file" name="allotment"/>
<br/>
MH-CET / JEE mains score card<br/>
<input type="file" name="MH-CET"/>
<br/><br/>
SSC Marksheet <br/>
<input type="file" name="fe_scorecard"><br/><br/>
.
.
//and more uploads likt this ---
//form ends with -----
.
.
<input type="submit" name="submit">
</form>
我的uploder.php是:
<?php
echo "I M ON PAGE FILE UPLODER";
include_once ('dbconfig.php');
include_once("check_login_status.php");
if(isset($_POST['submit']))
{
echo "FILE is catched successfully ";
//to print posted array form POST
print_r($_FILES);
// HERE is error of undifined index "ALLLOTMENT" and from this point code is not running
if (isset($_POST['allotment'])){
echo $_POST['allotment']['name'];
.
.
. --- and rest of uploading code (its working fine)--
.---if ends---
}
在ifset语句中我收到分配未定义索引错误的错误。
我试过的&gt;&gt;
我尝试将ENCTYPE放入我的att。 我试过PRINT_r来打印POSTED数组
我在print_r&gt;&gt;
中找到了什么 Array ( [allotment] => Array ( [name] => smalllogo.png [type] => image/png [tmp_name] => C:\wamp\tmp\php8756.tmp [error] => 0 [size] => 27252 ) [MH-CET] => Array ( [name] => [type] => [tmp_name] => [error] => 4 [size] => 0 )
表示“分配已过帐”。 但后来为什么我得到未定义索引的错误????? 请帮忙
答案 0 :(得分:0)
这里是错误......您正在处理未发布数据的文件。
// NOT $_POST[] GLOBAL BUT RATHER $_FILES[] GLOBAL
if (isset($_POST['allotment'])){
echo $_POST['allotment']['name'];
.
.
. --- and rest of uploading code (its working fine)--
.---if ends---
}
这就是它的编写方式:
<?php
if (isset($_FILES['allotment'])){ //<== $_FILES NOT $_POST
echo $_FILES['allotment']['name'];
.
.
. --- and rest of uploading code (its working fine)--
.---if ends---
}