Jump to content

Image in a blob column


mateamargo

Recommended Posts

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 [b]<img src="getimage.php?id=1" />[/b]

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?

Thanks.
Link to comment
Share on other sites

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.

upload_result.php
[code]
<?

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')";

$result=mysql_query($query);

echo"file uploaded";

}else{

echo "sorry no file uploaded";

}else{

echo"sorry wrong file type";

}else{

echo"Sorry wrong file size";
}
?>
[/code]
Link to comment
Share on other sites

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.

[b]getimage.php[/b] page
[code]
<?php
require_once("filedisplay.class.php");

$id = $_GET["id"];

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

header("Content-Type:".$row["file_type"]);
echo $row["file_blob"];

¿>
[/code]

[b]MAIN.php[/b] page
[code]
<img src="getimage.php?id=1" />
[/code]

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?

Thanks!
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.