feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am displaying the image stored in database. The problem what i am facing is, the image displayed is truncated and only the partial image is shown. Then if i makes request to another page(php page), then instead executing the php page
the browser displays the download page pop up. On downloading the php script page, the page if opened in text editor, shows some unreadable text (probably the truncated image content) and then proper php script. Following is the snapshot of page downloadedCode: Select all
Q@Q@Q@Q@Q@Q@Q@Q@Q@Q@ÿÙHTTP/1.1 200 OK
Date: Thu, 30 Aug 2007 07:11:09 GMT
Server: Apache/2.2.4 (Win32) PHP/5.2.3
X-Powered-By: PHP/5.2.3
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 523
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> Welcome to the Network</title>
<link rel="stylesheet" type="text/css" href="css/winxp.blue.css"/>
</head>
<body>
<div class="screenLayout">
<div class="headerContainer">
<div class="pageHeader">
</div>
</div>
<div align="right">
<a href="logout.php"> Logout</a>
</div><h3>Successfully logged Out.</h3>
<h2> <a href="index.php"> Login again</a></h2>
</body>
</html>The page which fetches the image from database is
Code: Select all
<?php
//getImage.php
function __autoload($class_name) {
require_once $class_name . '.php';
}
?>
<?php
$photo_id=$_REQUEST["photo_id"];
?>
<?php
session_start();
$authorized = false;
$loggedUser = $_SESSION["LOGGED_USER"];
if ($loggedUser == null) {
header('Location: index.php') ;
} else {
$authorized = true;
}
$photo_id=$_REQUEST["photo_id"];
?>
<?php
if ($authorized) {
require_once("dbConnection.php");
$con = getConnection();
//flush();
$selectPhotoQuery = "select * from photos where photo_id=".$photo_id;
$resultSet = mysql_query($selectPhotoQuery) or die("Error: coud not select image");
$recordSelected = mysql_numrows($resultSet);
if ( $recordSelected == 1) {
$row = mysql_fetch_array($resultSet);
$fileSize = $row["file_size"];
$fileType = $row["file_type"];
$fileImageContent = $row["photo_blob"];
} else {
//default image
$defaultFileName = "img/default.jpg";
$fp = fopen($defaultFileName, 'r');
$fileSize = filesize($defaultFileName);
$fileImageContent = fread($fp, $fileSize);
$fileType = "image/jpeg";
//$fileImageContent = addslashes($fileImageContent);
fclose($fp);
}
mysql_close($con);
header("Content-type: ".$fileType);
header("Content-length: ".$fileSize);
echo $fileImageContent;
exit();
} else {
header("Location: index.php");
}
?>Code: Select all
<?php
echo "\n<img src='getImage.php?photo_id=".$loggedUser->getUserPhotoId()."' width='100' height='100' border='1'>";
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[color=darkgreen][b]feyd[/b] | This topic has been split from another: http://forums.devnetwork.net/viewtopic.php?t=47552[/color]