myImageFile.php?id=$myImageID to myImageFileID.jpg conversion

Discussion in 'PHP' started by kigoobe, Sep 5, 2007.

  1. #1
    I was adding an automated PDF generation script in an existing website, where the images are storted in the blob field of a mySQL DB.

    But in TCPDF that I have found good to generate PDF files on the fly, it needs something like myImageFileID.jpg or myImageFileID.png to display the image in it's PDF document.

    Problem is, when the image is stored in the database, we use a link like myImageFile.php?id=$myImageID while displaying the image in a webpage.

    I need a solution where I can use myImageFileID.jpg or myImageFileID.png while keeping the images as binary in the blob field, instead of using a link like myImageFile.php?id=$myImageID.

    Cany anyone help?
    Thanks.
     
    kigoobe, Sep 5, 2007 IP
  2. EGS

    EGS Notable Member

    Messages:
    6,078
    Likes Received:
    438
    Best Answers:
    0
    Trophy Points:
    290
    #2
    You COULD use modrewrite for this. :D
     
    EGS, Sep 5, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Save this as .htaccess
    
    RewriteEngine On
    RewriteRule ^myImageFile(\d+)\.jpg$ myImageFile.php?id=$1
    
    Code (markup):
     
    nico_swd, Sep 6, 2007 IP