2016-06-04 7 views
-1

***** Was ist mein Fehler in kurz: - >>>PHP-Datei-Upload-Fehler - UNDEFINED INDEX

i zu einem Zeitpunkt mehr Bilddateien ist das Hochladen, für die im POST-Methode verwenden, um Dateien zu schreiben zu uploader.php Für meinen Testzweck ich versuche, nur die erste Datei (dh "Zuteilung") hochzuladen. JetztWenn ich eine Datei auswählen und klicken Sie auf Senden meine uploader.php ist nicht die POSTED "Zuteilung". es zeigt mir Fehler "Undefined index: Zuteilung in C: \ wamp \ www \ Pagination_test \ uploder.php on line 11"

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> 

MY uploder.php ist:

<?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--- 
    } 

Bei ifSet Aussage Ich bekomme Fehler von undefiniertem Indexfehler für die Zuteilung.

was ich versuchte >>

versuchte ich ENCTYPE in meinem von att setzen. ich print_r versucht POSTED Array

Was ich in print_r >>

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) 

bedeutet gefunden zu drucken "Zuteilung gebucht". Aber warum bekomme ich dann den Fehler von undefiniertem Index ????? pls Hilfe

Antwort

0

Hier war der Fehler ... Sie haben es mit einer Datei nicht gepostet Daten.

 // 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--- 
     } 

Dies ist, wie es geschrieben haben könnte:

 <?php 
      if (isset($_FILES['allotment'])){ //<== $_FILES NOT $_POST 

       echo $_FILES['allotment']['name']; 
       . 
       . 
       . --- and rest of uploading code (its working fine)-- 
       .---if ends--- 
      } 
+0

Ja paaren es funktioniert jetzt. Danke für die Hilfe ! –