browser doesn't load pdf files from mysql database
Posted by: jalasagar (117.211.103.---)
Date: February 10, 2014 11:10AM

<?php
$query= mysql_query("SELECT * FROM study_material,fourthyear_firstsemester where id='1'"winking smiley ;
header('Content-Description: File Transfer') ;
header("Content-type: application/pdf"winking smiley ;
header('Content-disposition:inline; filename="'.$query.'"');
@read($query);
echo $query;
?>

i use above code to read from table.i named the above table as read.php.when i'm executing above file loading appears in left bottom in chrome.but nothing loads.please help.thank you.



Edited 1 time(s). Last edit at 02/10/2014 11:11AM by jalasagar.

Options: ReplyQuote
Re: browser doesn't load pdf files from mysql database
Posted by: RiggsFolly (---.ppp.as43234.net)
Date: February 10, 2014 12:33PM

Thats because you are doing it wrong. Try something like this.

First you have to fetch the result of your query

Then setup your headers

Then send the file contents, which a realfile() will do

$result = mysql_query("SELECT * FROM study_material,fourthyear_firstsemester where id='1'" );

$obj = mysql_fetch_object($result);

header('Content-Description: File Transfer') ;
header("Content-type: application/pdf"winking smiley;;
header('Content-disposition:inline; filename="'.$obj.filename.'"');

readfile($obj->filename);

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote


Sorry, only registered users may post in this forum.