Re: Retrieving PDF/MSWord Files from Database

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



it's not advisable to put the binary data in a session
variable.

any way you can try this instead.

<?php
    header("Content-Type : application/pdf");
    session_start();
    $file = $_SESSION['resulta'];
    header('Content-Disposition: attachment;
filename="research.pdf"');
    echo $file;
?>


--- Roderick Ramos� <roderick_ramos@xxxxxxxxx>
wrote:

> Hello,
> 
> I am able to upload .pdf and .doc files into the
> MySQL database (using Medium Blob) but I can't
> retrieve or download them back. Can you help me
> download them?
> 
> What I did was the following pages (downloadpage.php
> and downloader.php):
> 
> 
> (1) downloadpage.php
> (trying to download pdf document with reference
> ID=143 from database)
> 
> ....
> 
> $result = mysql_query("SELECT fileContent FROM
> research WHERE referenceid=143") or die("MySQL Query
> Error:".mysql_error()."<br><br>"."The SQL was:
> $SQL<br><br>");
> 
>         $resulta = mysql_fetch_array($result)or
> die("error: in fetch name".mysql_error());
> 
>         $_SESSION['resulta'] = $resulta[0];
> 
>         mysql_close($link);
>         
>         ?>
>         
>                
>         <a href="downloader.php">download
> articles</a>
>             
> (2) downloader.php
> (process downloading)        
> 
> <?php
>     header("Content-Type : application/pdf");
>     session_start();
>     $file = $_SESSION['resulta'];
>     header('Content-Disposition: attachment;
> filename="research.pdf"');
>     readfile($file);
> ?>
> 
> 
> 
> 
> 
> Thank you very much!
> 
> 
> Regards,
> 
> Ricky
> 
> 
> 
> 		
> ---------------------------------
> New Yahoo! Messenger with Voice. Call regular phones
> from your PC and save big.
> 
> [Non-text portions of this message have been
> removed]
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux