Solved

Location redirection to FTP file

Posted on 2000-05-18
6
264 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

761 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