Jump to content

Image preview file name


joebudden

Recommended Posts

hi guys iv written this code to preview image files in the browser

[code]
<?php
require("cw1/connect.php");
require("cw1/dbselect.php");

//echo "<p>".'<a href="viewuploads.php">' . "Back" . "</a></p>";

$img = "select artefactId,filename,type,size,content from artefact where artefactId='".$_GET['id']."'";

$result = mysql_query($img,$con)or die('Error, query failed');

list($artefactId,$filename,$type,$size,$content) = mysql_fetch_array($result);

//header("Content-Disposition: attachment; filename=$filename");
header("Content-length: $size");
header("Content-type: $type");
header("Content-name: $filename");

echo $content;


mysql_close($con);
exit;
?>
[/code]

This works, however the filename is view.php which is the name of this page.

Its also view.php when i right click and save target

How can i have it so that the filename is that of the file ??

any help please
Link to comment
https://forums.phpfreaks.com/topic/33315-image-preview-file-name/
Share on other sites

Archived

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

×
×
  • 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.