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.


if(isset($_POST['add']) && $_FILES['filename']['size'] > 0)
$fileName = $_FILES['filename']['name'];
$tmpName  = $_FILES['filename']['tmp_name'];
$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);
    $fileName = addslashes($fileName);

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



Recommended Answers

All 2 Replies

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

ok thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.