Datei auswählen und Inhalt auslesen lassen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Datei auswählen und Inhalt auslesen lassen

    Hallo,


    ich würde gerne über ein Formularfeld eine Datei (Text) auswählen und den Inhalt dann mir ausgeben lassen
    Mein Script funktioniert allerdings nicht
    PHP Code:
        echo "<form enctype=multipart/form-data
     action=http://localhost/pages/test1/index.php?navigate=var3_file.php
     method=post>
              <fieldset>
                  <legend>Accessfile laden</legend>
              <p>
                  <label for=datei_id>Datei ausw&auml;hlen:</label>
                  <input name=datei id=datei_id type=file />
              </p>
              <p>
                  <input type=submit name=upload value=Laden />
              </p>
              </fieldset>
          </form><hr />"
    ;
        
           
          print 
    "<pre>";
          
    print_r($_FILES);  
          print 
    "</pre><hr /><pre>";

          if (
    $stream fopen($_FILES'r'))
            {
           
             echo 
    stream_get_contents($stream, -1);
          } 
    Bräuchte Hilfe...Merci!!
    Gruß
    Jimmy

  • #2
    Re: Datei auswählen und Inhalt auslesen lassen

    http://www.php.net/manual/de/features.file-upload.php
    http://www.php-faq.de/q/q-formular-upload-php4.html
    I don't believe in rebirth. Actually, I never did in my whole lives.

    Comment


    • #3
      PHP Code:
      if(isset($_POST['upload')){
        print 
      "<pre>";
        
      print_r($_FILES);  
        print 
      "</pre><hr /><pre>";
        if (
      $stream fopen($_FILES'r'))
        {
          echo 
      stream_get_contents($stream, -1);
        }
      }else{
        echo 
      "<form enctype=multipart/form-data
       action=http://localhost/pages/test1/index.php?navigate=var3_file.php
       method=post>
                <fieldset>
                    <legend>Accessfile laden</legend>
                <p>
                    <label for=datei_id>Datei ausw&auml;hlen:</label>
                    <input name=datei id=datei_id type=file />
                </p>
                <p>
                    <input type=submit name=upload value=Laden />
                </p>
                </fieldset>
            </form><hr />"
      ;

      Du musst schon erst feststellen ob das Form bereits verschickt wurde.

      Gruss

      tobi
      Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

      [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
      Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

      Comment


      • #4
        Original geschrieben von jahlives
        PHP Code:
        if(isset($_POST['upload')){
          print 
        "<pre>";
          
        print_r($_FILES);  
          print 
        "</pre><hr /><pre>";
          if (
        $stream fopen($_FILES'r'))
          {
            echo 
        stream_get_contents($stream, -1);
          }
        }else{
          echo 
        "<form enctype=multipart/form-data
         action=http://localhost/pages/test1/index.php?navigate=var3_file.php
         method=post>
                  <fieldset>
                      <legend>Accessfile laden</legend>
                  <p>
                      <label for=datei_id>Datei ausw&auml;hlen:</label>
                      <input name=datei id=datei_id type=file />
                  </p>
                  <p>
                      <input type=submit name=upload value=Laden />
                  </p>
                  </fieldset>
              </form><hr />"
        ;

        Du musst schon erst feststellen ob das Form bereits verschickt wurde.

        Gruss

        tobi
        hä? da geht trotzdem nix...

        Comment


        • #5
          Eine Möglichkeit wäre es die HTML Attribut Werte in " und " zu schreiben (das habe ich vorhin übersehen).
          Schickst du das Formular an sich selber ?
          Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

          [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
          Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

          Comment


          • #6
            Original geschrieben von jahlives
            Eine Möglichkeit wäre es die HTML Attribut Werte in " und " zu schreiben (das habe ich vorhin übersehen).


            das geht doch nicht, weil es ne echo-ausgabe ist. dann würde beim ersten attributs-hochkomma ein fehler kommen.

            Schickst du das Formular an sich selber ?

            jap, das ist der pfad


            PHP Code:
            <form enctype=multipart/form-data action=http://localhost/pages/test1/index.php?navigate=var3_file.php 

            Comment


            • #7
              das geht doch nicht, weil es ne echo-ausgabe ist. dann würde beim ersten attributs-hochkomma ein fehler kommen.
              So ne K...e ! Such mal in der Suma deiner Wahl nach php string escape
              Und wenn du das Form an sich selber schickst dann
              PHP Code:
              echo "<form action=\"".$_SERVER['PHP_SELF']."?navigate=var3_file.php\" method=\"post\">"
              Wobei Strings eigentlich in ' und ' gehören, dann sparst du dir das Escapen bei der HMTL Ausgabe

              Gruss

              tobi
              Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

              [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
              Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

              Comment


              • #8
                schau dir mal das tutorial an, da wird alles erklärt.

                btw: stream_get_contents ist hier völlig sinnfrei.

                gruß
                peter
                Nukular, das Wort ist N-u-k-u-l-a-r (Homer Simpson)
                Meine Seite

                Comment


                • #9
                  Original geschrieben von JimmyPage
                  das geht doch nicht, weil es ne echo-ausgabe ist. dann würde beim ersten attributs-hochkomma ein fehler kommen.
                  Tu dir und uns einen Gefallen - lasse so lange bitte die Finger von etwas komplexeren Sachen wie Dateiuploads, bis du wenigstens die Grundlagen der Syntax von PHP kannst.
                  I don't believe in rebirth. Actually, I never did in my whole lives.

                  Comment

                  Working...
                  X