Solved

Location redirection to FTP file

Posted on 2000-05-18
6
259 Views
Last Modified: 2013-12-25
I've written a Perl script to handle redirection from my site to files hosted on another website.

I've used
print "Location: http://www.etc.com/file.hqx", "/n/n"; which works with no problems

However, some of the files I wish to relocate to are hosted on an FTP server.
When I try print "Location: ftp://ftp.etc.com/file.zip","/n/n";
the file downloads ok, but the filename and type are set incorrectly. Instead of the download being called file.zip I get redirect.pl (the name of my script). If I rename the file on the desktop file.zip I can decompress the file ok.

I'm using IE5 on the mac to try this.

Any help appreciated

0
Comment
Question by:bodoni
  • 4
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
maneshr earned 100 total points
ID: 2821215
you can fix this problem by appending the name of the downloaded file to the end of your PERL script.

Lets say the URL that does is redirection is...

http://www.yourserver.com/cgi-bin/redirect.pl

just change it to ....

http://www.yourserver.com/cgi-bin/redirect.pl/file.zip 

and then try.

NOTE: this solution does not work on NT with IIS4.0 since IIS does not support appending  anything after the script name.
=============================================
Another approach that works across systems, assuming you are sending the MIME header across is the foll.

In the headers which you output, you could try putting the following:
print "Content-type: application/octet-stream\n";
print "Content-disposition: filename='file.zip'\n\n"


Hope that helps.
0
 

Author Comment

by:bodoni
ID: 2824885
maneshr,
 Thanks for the help so far... Ive tried both suggestions, but neither worked.
  Appending the filename didn't change anything.
  Adding the MIME headers did't work either. Each time the file downloads ok, but the filename and type are wrong.

I've tried the original script browsing from IE5 on the PC, and Netscape 4 on the mac and both work fine. Typical.....

Trying various combinations, I have to have narrowed the problem down. It looks like the remote site is having no problem naming the file, but for some reason IE5 on the mac is hasn't realised the location and filetype has changed. All I get in the download manager is redirect.pl as the filename.

Lee
0
 

Author Comment

by:bodoni
ID: 2824981
I've found the answer

print "Content-type: application/zip\n";
print "Content-disposition: file; filename=file.zip\n";
print "Content-location: ftp://ftp.etc.com/file.zip", "\n\n";

Works fine....

Hooray

This has the right filename, and filetype

Content-type: application/octet-stream didn't arrive as a zip file and I has to decompress the file manually.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:bodoni
ID: 2825370
Here we go again.
I was a bit hasty saying everything worked.
I've just checked the file that downloaded and its completely blank (0 bytes)

Using Content-type & Content-disposition headers and Location: the file downloads ok, but the wrong filename and type

It's as though IE5 is ignoring the type and filename, whatever you tell it.
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2825661
"....I was a bit hasty saying everything worked. ...."

Don't worry. if in the end you dont get a working answer, i will refund you your points.

Right now, when you go to the ftp site, do you usually provide some kind of username/password?



0
 

Author Comment

by:bodoni
ID: 2826478
maneshr,

The FTP site has anonymous access so I don;t think there is a problem there.

I've kind of got a workaround that will have to do.

The script I was writing was to try and centralize downloading files from remote sites.

So a link from the web page would be
http://www.mysite.com/redirect.pl?NEW_URL=macsoftware
or http://www.mysite.com/redirect.pl?NEW_URL=pcsoftware

The script would then point to the correct location of the file depending on the argument. That means I only have to change the script file if any of the locations change and not individual web pages.

If I have the link on the web page as http://www.mysite.com/redirect.pl/newfile.zip?NEW_URL=pcsoftware I get the right filename, but the wrong filetype ( IE5 thinks its an IE file)

Previously I was adding the filename after the ? arguments.

It's not ideal, as the user would have to decompress the file manually, but at least is should be fairly obvious to do so.

Thanks for your help
Lee
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reading variable length EBCDIC in SAS 9 108
EXCHANGE 2007, SCRIPTS 67 79
Recursive folder search vbscript 7 48
Run command in each subfolder using batch file 7 59
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question