Solved

Location redirection to FTP file

Posted on 2000-05-18
6
265 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

738 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