Solved

Location redirection to FTP file

Posted on 2000-05-18
6
258 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

932 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now