Link to home
Start Free TrialLog in
Avatar of funkyshah
funkyshah

asked on

"Content-Type: application/x-unknown " , different response in IE 4.0 & 5.0

To make the browser ask "Save File to Disk" , I make "Content-Type: application/x-unknown " and download the file from the remote location successfully. This works perfectly fine in IE 5.0 and NN 4.0 onwards but in IE 4.0 , It displays the file to be downloaded instead of asking "Save File to Disk"

Help Please URGENT

Here is the full code
print "Content-Type: application/x-unknown\n";
print "Content-Disposition: attachment; filename=$file_name\n\n";
$output_file = read_file($target_file);
print $output_file;

## Sub read_file
sub read_file {
    local($fname) = @_;
    local($content);

    open(FILE, "<$fname") ||  print "cannot open ".$!;

    while(<FILE>)
    {
        $content .= $_;
    }
    close(FILE);

    return $content;

Avatar of maneshr
maneshr

funkyshah,

                    i would suggest you try this.

                    i addition to sending an unknown header, try changing the extension of the file to xyz or something that you system will
                    not understand.

                    Eg if you send a file with .doc extension, IE will try to launch Word to open it since .doc is mapped to MS-Word in your
                    system registry.

                    Therefore if you send an unknown extension, and assuming that that extension is not mapped to any app on the system, it
                    should prompt the user with the save dialog box.

                    Hope that helps
any luck on this so far??

Avatar of funkyshah

ASKER

Manesh ,

Nope , Frankly I haven't tried the last one that is to change the extension to something gibberish . I need couple of more days to clear that. I will get back to u on this very soon. Gimme 2 days.
cool!! Wish you all the best :-)
Hi Manesh ,

It works perfectly fine except that when it asks the user 'Save File to Disk' appears with the .xxx extension. That is one reason why It is not accepted here in my office. Because the user might not notice the extension and might save it resulting in an unknown file in his local. So the problem still remains open and looks like there could'nt be any solution around the corner.
I am afraid I am not giving the points to you as I would like to keep the question open ........
Sorry !
ASKER CERTIFIED SOLUTION
Avatar of maneshr
maneshr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yup that's one way it could be done.
Although I am not doing it that way right now as it is meant for a site which gives free space to users to upload/dowmload files and want a simplest possible solution. The office guys do not want any hassles of asking the user to download a small exe to do that. Although it is a simple issue but then that's the way things work when u work for somebody else.

I am not sure whether I should give u the points.

I guess I'll give u .....
Thanks !
i understand your predicament, especially since i was myself facing a similar situation when i was developing a very similar web site (www.diskonnet.com).

i suggest you enroll yourself at this site and see how it works. it basically uses ASP with PERL and a bit of javascript to provide a very handy functionality.

Who knows you might get some hints which will help you or at least guide you towards the solution.

Rgds