Tracing redirect URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vytis
Forum Newbie
Posts: 2
Joined: Wed Aug 09, 2006 4:44 pm

Tracing redirect URL

Post by vytis »

Hi,

I did a lot of googling on this subject, but still no luck and I'm now begining to lose hope.
I am trying to implement a function where a user can paste a link (URL) to a file he/she wants to download and the script outputs the file name, type and size (this is just a small bit of my larger project). Very often links are not direct and redirected through php scripts. Such as this mp3 on my own band's website running a CMS:

http://www.soyamodified.com/download.ph ... 91617,22,1

When you click on it in the browser, it lets you download the file as "Soya Modified - 05 Tune Up Your Life (demo).mp3" - is there a way of "converting" that URL into this filename through PHP?

Thank you very much and hopefully I've explained my problem clearly enough.

ANY ideas appreciated!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Is this supposed to be done blindly or by selecting from a list?
vytis
Forum Newbie
Posts: 2
Joined: Wed Aug 09, 2006 4:44 pm

Post by vytis »

Users will paste any URL they like (not from a list), which the script will then try to download to the server.
The problem is that often they might paste non-direct URLs (redirection links) because on a browser they point to the actual file anyway.

Is there a way to simulate browser-style handling of URLs (such as used by download managers - where even if you type a redirect URL, it will download the actual file, not the HTML that contains redirection code?

Many thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

cURL is your new friend. Image
Post Reply