0

Hi, I have here a code for saving a pdf file to mysql database as blob. may problem is how can i retrieve pdf blob in php. thank you.

<?php


if(isset($_POST['add']) && $_FILES['filename']['size'] > 0)
{
$fileName = $_FILES['filename']['name'];
$tmpName  = $_FILES['filename']['tmp_name'];
$fileSize=$_FILES['filename']['size'];
$fileType = $_FILES['filename']['type'];
$fileType=(get_magic_quotes_gpc()==0 ? mysql_real_escape_string(
$_FILES['filename']['type']) : mysql_real_escape_string(
stripslashes ($_FILES['filename'])));

$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
    $fileName = addslashes($fileName);
}


    $sql2="UPDATE productitem SET filename = '$fileName', file = '$content', type = '$fileType', size = '$fileSize' where itemcode='$itemcode'";

    mysql_query($sql2);

?>
2
Contributors
2
Replies
5
Views
3 Years
Discussion Span
Last Post by zelanne74
0

Please refrain from posting the same question multiple times. Since you included more information in this thread, we will keep this one active.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.