Jump to content

Archived

This topic is now archived and is closed to further replies.

mateamargo

Image in a blob column

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.

Share this post


Link to post
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]

Share this post


Link to post
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!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

×

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.