i want to display the stored image in fdpf.

thank you for reply.but i want to databse stored image display on fdpf.

Is the image stored in a database (as a blob) or is it just a path to the image stored in the DB?

image are stored in blob

This is a bit tricky for me, I must admit :-). I have never used this approach. You could try sending the blob data base64 encoded to the Image method and see what you get. This is really a wild guess and I do not have time to try it right now. Maybe this link can help you: http://stackoverflow.com/questions/13225726/i-need-my-php-page-to-show-my-blob-image-from-mysql-database

I will give it a try tonight if I find some time. Meanwhile I hope other members with experience in this will be able help.

okay

hello sir iam waiting for our reply.iam trying to also DB image path are displayed in fpdf but image are not show in fdpf..how to get the image path from DB and show the image in fdpf.

If you have image path in the DB and the image stored in the filesystem, then it is easy:

First get the image path form the DB, i.e:

// establish a link to the database
$link = ...

// a query to read the path
$query = "SELECT imagePath FROM images WHERE imageId=$someImageId";)

// send the query
$result = mysqli_query($link, query);

// get the row
$row = mysqli_fetch_row($result);

// image path is the first (and the only) element of the $row array
$imagePath = $row[0];

Then assemble the PDF document and use the fpdf image method:

$pdf = new FPDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->Image($imagePath);
$pdf->Output();

For optional parameters for the image method see the FPDF manual.

For retrieving an image stores in a blob I did not have time to research. What was the method to store the binary data? Was it using a function file_get_contents? Was the data base64 encoded?

This is my Html Form Code

<form enctype="multipart/form-data" action="uploader.php" method="POST"> 
<input type="hidden" name="MAX_FILE_SIZE" value="100000" /> 
Choose a file to upload: <input name="uploadedfile" type="file" /><br /> 
<input type="submit" value="Upload File" name="upload"/> </form>

Upload file code

 <?php
    //connecting to database

    $db = mysql_connect("localhost:3306","root","") or die(mysql_error());

     //selecting our database

    $db_select = mysql_select_db("uploadimage",$db) or die(mysql_error());

    if(isset($_POST['upload'])){//button for Upload
    $target_path  =  "uploads/";
    $target_path  =  $target_path  .  basename($_FILES['uploadedfile']['name']);
    if (move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    $query =mysql_query( "INSERT INTO image1 (name) values ('$target_path')");//insertion to database
    echo "The file " . basename($_FILES['uploadedfile']['name']) . " has been uploaded";
        header('Location: pdffile.php');
    } 
    else {
    echo "There was an error uploading the file, please try again!";
    }
    }
    ?>

fdpf code

<?php
require("fpdf.php");  
class PDF1 extends FPDF
{
// Page header
function Header()
{
    // Logo
    $this->Cell(0,10,'APPLICATION FORM FOR ADMISSION INTO MEDICAL PG DEGREE/DIPLOMA COURSES',0,0,'C');
    $this->Ln(6);
    $this->Cell(0,10,'UNDER MANAGEMENT QUOTA FOR THE ACADEMIC YEAR 2014-2015',0,0,'C');
    $this->Ln(6);
    $this->Cell(0,10,'-----',0,'C');
    // Line break
    $this->Ln(15);
}
}

$link=mysql_connect('localhost:3306','root','');
mysql_select_db('uploadimage');
$pdf = new PDF1();
 $pdf->AddPage();
$query=mysql_query("select name from image1 where id=1");
$result = mysql_query($link, query);
header("Content-type: image/jpeg");
$row=mysql_fetch_row($result);
$name=$row[0];
$pdf->Image($name);
$pdf->Cell(0,10,'id'.$row['id'],0,1);
$pdf->Cell(0,10,'name'.$row['name'],0,1);


$pdf->Output(".pdf"); 
header('Location: '. ".pdf");
?>

i am trying to get the image path are displayed from db in pdf.The problem is when iam generate the pdf.one message are display like "The image "http://localhost/uploader/pdffile.php" cannot displayed,because it contains error"what is that meaning.

First check if you got the path to the image correctly. Put this temporary debug code immediatelly after line 27 in your fpdf code:

die($name);

This will display the path to your image. Check it whether is OK. Please post it here.

BTW, have you tried to ask the question on the fpdf forum?

as you said replace the line no 27 like die(name);iam put that code in line no 27.but the same error is display The image "http://localhost/uploader/pdffile.php" cannot displayed,because it contains error.like that..please tell me your email address sir i will send my code.

You can zip the affected scripts and send them as a personal message to me here. Pease include the database structure and a few rows of data (export in sql format from phpmyadmin).

should line 25 not be header('Content-type: application/pdf'); ?

iam replace the line 25 as you said header('content-type:application/pdf');
one error are displayed like "This pdf document may not be displayed incorrectly" like that.

how can i send you personal message sir.

If you click on my avatar or name on the left side of the post you get to my profile page. Find a button there that says Send private message. I have just sent you a provate message so you can also just reply to it.

commented: can i get your email? +0

i want to send my code in zip format to you..but there is no option in zip format.how can i send to you in zip format sir

Sory, I did not know this but it seems it is not possible. I sent you my email in a PM.

okay.i hope your email address send to me..i am waiting for that.

I have already done that. Have a look at your personal messages.

i didn't see any your email address my personal message where is it sir

I sent you a message 11 hours ago with my gmail email address. There is a menu on top of the forum page that says Private messages. Click on it and you will see my message.

$pdf->Cell(0,10,'id'.$row['id'],0,1); $row['id'] don't exist : your query only gets the name.
it sould be $pdf->Output($name,I); or $pdf->Output();

header('Location: '. ".pdf"); you already send the pdf to the bouwser, also requires a full filename or url

Member Avatar for iamthwee

You can attach your zip file on DW assuming it is not that large. That way you get many eyes looking over it.

Always better IMO.

commented: Totally agree. +9

OK, I had a look at the files that you sent me. In this post I will post a file that is causing troubles. In next post I will describe the solutions. The troublesome script is:

<?php
header('Content-type: image/jpeg');
header('Content-type: application/pdf');
require("fpdf.php");
class PDF1 extends FPDF
{
    // Page header
    function Header()
    {
        // Logo
        $this->Cell(0,10,'APPLICATION FORM FOR ADMISSION INTO MEDICAL PG DEGREE/DIPLOMA COURSES',0,0,'C');
        $this->Ln(6);
        $this->Cell(0,10,'UNDER MANAGEMENT QUOTA FOR THE ACADEMIC YEAR 2014-2015',0,0,'C');
        $this->Ln(6);
        $this->Cell(0,10,'-----',0,'C');
        // Line break
        $this->Ln(15);
    }
}
$link=mysql_connect('localhost:3306','root','');
mysql_select_db('uploadimage');
$pdf = new PDF1();
$pdf->AddPage();
$query=mysql_query("select name from image1 where id=1");
$result = mysql_query($link, $query);

$row=mysql_fetch_row($result);
$name=$row[1];
$pdf->Image($name);
$pdf->Cell(0,10,'id'.$row['id'],0,1);
$pdf->Cell(0,10,'name'.$row['name'],0,1);
$pdf->Output(".pdf");
header('Location: '. ".pdf");
?>
Be a part of the DaniWeb community

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