phpbar.de logo

Mailinglisten-Archive

[php] Bilder in der Datenbank, Fehler im Upload

[php] Bilder in der Datenbank, Fehler im Upload

Nicole Knodt php_(at)_phpcenter.de
Wed, 29 Aug 2001 17:12:04 +0200 (GMT+02:00)


hi,=20
ich m=F6chte JPEG-Photos direkt in der Datenbank speichern. Ich benutze daz=
u eine Oracle8 Datenbank und logisch php.
leider gibt es in meinem script noch Unstimmigkeiten. Ich habe versucht mei=
n Beispiel m=F6glichst nah an eines im Manual anzupassen, aber leider funkt=
ioniert das nicht so ganz.

<?php
        if(empty($attachment)){
 ?>
 <form action=3D"insert_aufn.php" method=3D"post" enctype=3D"multipart/form=
-data">
 Upload Photo: <input type=3D"file" name=3D"attachment"><br>
 <input type=3D"submit" value=3D"Upload"> - <input type=3D"reset">
 </form>
 <?php
   } else {
      // $lob_upload contains the temporary filename of the uploaded file


      $conn =3D OCILogon("snoopy", "scott", "trier.world");
      //$lob =3D OCINewDescriptor($conn, OCI_D_LOB);
      //echo("insert into photolib (PHOTONR, SCREENSHOT) values (photo_seq.=
NEXTVAL, '$attachment_data')"); // returning SCREENSHOT into :SCREENSHOT");
      $stmt =3D OCIParse($conn,"insert into photolib (PHOTONR, SCREENSHOT) =
values (photo_seq.NEXTVAL, ':SS') returning PHOTONR into :PN");
      $pn =3D OCINewDescriptor($conn, OCI_D_ROWID);
      $attachment_data =3D OCINewDescriptor($conn, OCI_D_LOB);
      OCIBindByName($stmt, ':PN', &$pn, 32);
      OCIBindByName($stmt, ':SS', &$attachment_data, -1, OCI_B_BLOB);

      // Prepare Attached files
      if ($attachment !=3D 'none')
      {
         // Read temporary file which contains the uploaded
         $attachment_data =3D addslashes(fread(fopen($attachment,"r"),files=
ize($attachment)));
         //$attachment_size =3D filesize($attachment); // size of the file
         //$attachment_name =3D $attachment_name; // name of the uploaded f=
ile
         //$attachment_type // MIME type of the uploaded file
      }
      else
      {
         echo "Keine Datei ausgew=E4hlt!";
      }

      OCIExecute($stmt);
      if($lob->savefile($lob_upload)){
         OCICommit($conn);
         echo "Blob successfully uploaded\n";
      }else{
         echo "Couldn't upload Blob\n";
      }
      $lob->free();
      //OCIFreeDescriptor($lob);
      OCIFreeStatement($stmt);
      OCILogoff($conn);
   }
 ?>

</body></HTML>

Und das sind die dazugeh=F6rigen Fehlermeldungen:
Warning: OCIBindByName: ORA-01036: illegal variable name/number in
          /usr/local/apache/htdocs/phptest/insert_aufn.php on line 39

          Warning: OCIStmtExecute: ORA-01465: invalid hex number in
          /usr/local/apache/htdocs/phptest/insert_aufn.php on line 55

          Fatal error: Call to a member function on a non-object in
          /usr/local/apache/htdocs/phptest/insert_aufn.php on line 56

Vielen Dank schon mal an alle, die Ihre Zeit investieren.
Verzweifelte Gr=FC=DFe
sancho
______________________________________________________
http://firemail.fireball.de - Ihr Briefkasten im Web.=20
Einfach, schnell, sicher.



php::bar PHP Wiki   -   Listenarchive