Re: Can I open an image from HTML direct in a external-program?



<michelr.be@xxxxxxxxx> wrote in message
news:ee37976b-64cc-4f6f-a4dd-dbc6047f52cf@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
How do I write in HTML-code where as one clicks on a displayed jpg,
the assigned computer program opens it instead of the internet-
explorer?

This way (on my PC) "Windows Picture and Fax Viewer" should open the
JPG when clicking on that JPG image dispayed in IE.
So <A> and <IMG> always reloads the *.JPG in the browser. Maybe I need
to use <OBJECT>, but how?


The photo-sharing website "flickr" uses some kind of scripting to force the
"open or save" dialog box to open rather than opening the file in the
browser. I use a php script - the filename is passed to the script in the
url, in this case it is used for .pdf files, so the URL
"http://www.mysite.example/pdf.php/myfile.pdf"; would pass the filename
"myfile.pdf" to "pdf.php".

The script passes the file back to the browser as its output which brings up
the dialog box to open or save.

For a working example try this URL (2.14MB .pdf file)
http://www.northantscamra.org.uk/pdf.php/overthebarrel-nov2007.pdf

php script below:

<?php

if ( substr($_SERVER['PATH_INFO'], 1) == "" ) {

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.mysite.example/404.html";);
exit();
}

$pdf = substr($_SERVER['PATH_INFO'], 1);
if(preg_match('/^[a-zA-Z0-9_\-]+.pdf$/', $pdf) == 0) { print "Illegal name:
$pdf"; return; } header('Content-type: application/pdf');
header('Content-disposition: Attachment; filename=' . $pdf); readfile($pdf);

?>

Short answer (I don't think it can be done in HTML)

-=# Amos E Wolfe #=-


.



Relevant Pages