Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting to FTP URL with username and password in Safari

I've got a problem with Safari I haven't been able to solve:

<?php
    header("Location: ftp://username:[email protected]/somefile.zip");
?>

This code-snippet works in every browser (Fx, Chrome, IE7-9), but not in the latest Safari, which tells me that I don't have permission to view the page (that is, it redirects to the correct page [somedomain.org] with the correct protocol, but does not process the authentication data).

Interestingly it works when I copy it directly to the address bar or when I put in in an <a>-tag an click on it. Is this a Safari bug, or am I missing something here, which the other browsers ignore? And if it's a Safari bug, is there some kind of workaround?

like image 551
fresskoma Avatar asked Aug 11 '11 16:08

fresskoma


People also ask

Does Safari support FTP?

Safari does not support browsing FTP sites (displaying directory listings). Given a ftp: URL for a specific file, it will display or download it, but URLs for directories will be passed to the Finder instead.

How do I enable FTP URL on iPhone?

Run the File Explorer on iPhone, go to its New Connection screen, scroll down to the button, you will see the Network Neighborhood section where your local FTP server can be detected automatically by the FTP client on iPhone. Tap on it, then log in using your computer login user ID and password.


1 Answers

Try:

header('HTTP/1.1 301 Moved Permanently');
header('Location: ftp://username:[email protected]/somefile.zip');

if it doesn't work try :

echo <<< EOF
<META HTTP-EQUIV="Refresh" CONTENT="0;URL=ftp://username:[email protected]/somefile.zip">
EOF;

Or:

header ('Location: ftp://username:[email protected]/somefile.zip');   
header ('Content-Length: 0');

The last solution I got from: http://www.ultrashock.com/forum/viewthread/90424/

like image 150
Pedro Lobito Avatar answered Oct 18 '22 14:10

Pedro Lobito