the script that show image is :
<?php
include('dbinfo .inc.php');
mysql_connect($ localhost,$user name,$password) ;
@mysql_select_d b($database) or die( "Unable to select database");
$query = "SELECT file,filesize,f iletype FROM user WHERE id=1;";
$result=mysql_q uery($query);
mysql_close();
$file=mysql_res ult($result,0," file");
$filesize=mysql _result($result ,0,"filesize") ;
$filetype=mysql _result($result ,0,"filetype") ;
header('Content-Type: '.$filetype);
header("Content-Disposition: attachement\n") ;
print $file;
?>
it's work fine execpt it show the image as a attachement
(Save as... window), so Apache, mysql, php seem to work fine.
the problem is only on http header of image i think.
i want the image directly so, i use this :
<?php
include('dbinfo .inc.php');
mysql_connect($ localhost,$user name,$password) ;
@mysql_select_d b($database) or die( "Unable to select database");
$query = "SELECT file,filesize,f iletype FROM user WHERE id=1;";
$result=mysql_q uery($query);
mysql_close();
$file=mysql_res ult($result,0," file");
$filesize=mysql _result($result ,0,"filesize") ;
$filetype=mysql _result($result ,0,"filetype") ;
header('Content-Type: '.$filetype);
print $file;
?>
it's don't work, firefox gave me "The image
cannot be displayed, because it contains error."
IE show me nothing at all.
any one have a idea ?
----------------------------------------------------
Windows NT 5.1 build 2600 (XP Professional English)
Apache 2.0.54, running as a server
PHP Version 5.0.4 running as module
MySQL 4.1.7 (a dll from php)
Firefox english 1.0.4
Internet Explorer 6
theonlydrayk@gm ail.com
<?php
include('dbinfo .inc.php');
mysql_connect($ localhost,$user name,$password) ;
@mysql_select_d b($database) or die( "Unable to select database");
$query = "SELECT file,filesize,f iletype FROM user WHERE id=1;";
$result=mysql_q uery($query);
mysql_close();
$file=mysql_res ult($result,0," file");
$filesize=mysql _result($result ,0,"filesize") ;
$filetype=mysql _result($result ,0,"filetype") ;
header('Content-Type: '.$filetype);
header("Content-Disposition: attachement\n") ;
print $file;
?>
it's work fine execpt it show the image as a attachement
(Save as... window), so Apache, mysql, php seem to work fine.
the problem is only on http header of image i think.
i want the image directly so, i use this :
<?php
include('dbinfo .inc.php');
mysql_connect($ localhost,$user name,$password) ;
@mysql_select_d b($database) or die( "Unable to select database");
$query = "SELECT file,filesize,f iletype FROM user WHERE id=1;";
$result=mysql_q uery($query);
mysql_close();
$file=mysql_res ult($result,0," file");
$filesize=mysql _result($result ,0,"filesize") ;
$filetype=mysql _result($result ,0,"filetype") ;
header('Content-Type: '.$filetype);
print $file;
?>
it's don't work, firefox gave me "The image
cannot be displayed, because it contains error."
IE show me nothing at all.
any one have a idea ?
----------------------------------------------------
Windows NT 5.1 build 2600 (XP Professional English)
Apache 2.0.54, running as a server
PHP Version 5.0.4 running as module
MySQL 4.1.7 (a dll from php)
Firefox english 1.0.4
Internet Explorer 6
theonlydrayk@gm ail.com
Comment