Jump to content


Image in a blob column

  • Please log in to reply
3 replies to this topic

#1 mateamargo

  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 07 June 2006 - 01:40 PM

I have an image in a blob column.
In a page called getimage.php I do an echo of the content, and the image displays correctly in the main.php

so, I use <img src="getimage.php?id=1" />

The problem is when I save the picture to the disk the name is getimage.jpg. I have the original name saved into the database, is there any way to display the original name when saving?


#2 redarrow

  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 07 June 2006 - 02:45 PM

You need to put the name of the input form of uploading file as userfile_name.

In the database also put userfile_name.

Then somthink like this think as i am a learner good luck.


database connection

if(!$userfile=="none") {

echo" sorry no file specified";


$type="$_FILES['userfile']['type']=='audio/mpeg' ";

$size="$_FILES['userfile']['size']=='20000' ";

if($size=='20000') {

if($type) {

move_uploaded_file($userfile, "pic folder name/",$userfile_name) {

$query="insert into music values('userfile_name')";


echo"file uploaded";


echo "sorry no file uploaded";


echo"sorry wrong file type";


echo"Sorry wrong file size";

Wish i new all about php DAM i will have to learn

#3 mateamargo

  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 08 June 2006 - 01:35 AM

I think you misunderstood my problem.

I have already the file in my database into a longblob column, and also I have the original file name and the file type.

getimage.php page

$id = $_GET["id"];

$ob_disp = new filedisplay();
$row = mysqli_fetch_array($ob_disp->get_by_id($id));

echo $row["file_blob"];


MAIN.php page
<img src="getimage.php?id=1" />

The image displays correctly, the ID 1 is just for the example.
I want that when I save the image into my disk (right click on it and "Save image as...") appears the real image name (that I have stored in "file_name" field into my database.

It is clear now?


#4 poirot

  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 08 June 2006 - 01:41 AM

As this behavior is controlled by the browser, I don't think it's possible to change it with PHP or maybe anything.

Maybe you COULD use javascript, but for "exotic" features like this, guaranteeing cross-browser compatibility is a problem.
~ D Kuang

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users