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

A

Anon

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?
 
A

Amos E Wolfe

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 #=-
 
A

Andy Fish

AFAIK you're right

the key is in sending the content-disposition header. this cannot be
mimicked using javascript

it's similar to this FAQ: http://www.jibbering.com/faq/#FAQ4_33

Andy


Amos E Wolfe said:
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 #=-
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top