Re: image upload/display problem part II
| From: | Siim Einfeldt aka Itpunk | Date: | Thu, 28 Dec 2000 14:55:18 +0000 |
| Subject: | Re: image upload/display problem part II | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-32080@lists.php.net to get a copy of this message | ||
Huh, I got it to work, the code that I sent previously, was a bit buggy
and the real problem was in my server...that will be my question for
future...:-)
>
> This is the code that was sent to me (by Chris Lee). I think it should
> work and he said it does, but I still can`t get it to display the
> image. All the information is below:
>
> // Here`S the form and the image uploader
> <?php
> include("connect.inc.php3");
> echo "<form method=post enctype='multipart/form-data'
> action='$PHP_SELF'>\n";
> echo "<input type=file name=file>\n";
> echo "<input type=submit>\n";
> echo "</form>\n";
>
> if (isset($file) AND $file != "none"){
> $file_data = fread( fopen($file, 'r'),
> filesize($file) );
> $result = mysql_query("INSERT INTO temptable VALUES
> ('','$file_name', '$file_type', '$file_data')" );
> echo mysql_error();
> }
>
> ?>
>
>
>
>
> // This should show the picture
> <?
> include("connect.inc.php3");
> $query = "SELECT * FROM temptable";
> $result = mysql_db_query("bt", $query);
> $r = mysql_fetch_array($result);
>
> Header("Content-Type: {$r["file_type"]}");
> echo $r["file_data"];
> exit();
> ?>
>
> // This is the database table
> CREATE temptable(
> id INT NOT NULL AUTO_INCREMENT,
> file_name VARCHAR(30),
> file_type VARCHAR(50),
> file_data BLOB,
> primary key (id));
>
>
> So much trouble with such an easy thing...if you know where`s the problem,
> please let me know asap.
>
>
> Thanks
> Siim Einfeldt
>
>