Page 1 of 1

Can I use Forms to get username and passwords for FTP?

Posted: Fri Sep 23, 2005 9:52 am
by murph2481
Is there a way I can write a form that captures username and password and sends it to an ftp server?

I know I could do a submit and do something like ftp://$username:$password@ftp.domain.com

But wondering if there are any other ways...

Thanks in advance,
Dan

Posted: Fri Sep 23, 2005 9:54 am
by feyd
what are you wanting to do (end goal) with this?

there are php internal ftp functions that may help, if you want to "hide" it...

FTP Form username and password

Posted: Fri Sep 23, 2005 10:00 am
by murph2481
This is going back to the same problem as the....if this browser do this....if that browser do that. I just thought maybe there was a way I could submit username and password to a FTP and get in other than in the URL or maybe there are some specail charcters i can use in the URL?

My employeer wants a link to his FTP server on his site. Well I cannot just put a link because it tries to login annonymously. If i supply a username it prompts me for a password and then i can enter on and get in. Problem is my username has an @ (user@domain.com) in it which throws off IE and Firefox. I can use a + (user+domain.com) instead but that only works on IE, Firefox doesn't like it. So instead of codeing if else statements based on the hundreds of browsers out there was wondering if i could send the username and password to the FTP site through form submission.

Basically i am looking for a way to always force a prompt for login information for the FTP server coming through the website. I know this is tough because of the different browsers but that is why i am on the forums asking about it :lol:

Thanks,
Dan

Posted: Fri Sep 23, 2005 10:09 am
by feyd
try to rawurlencode() the username and password

as an example:

Code: Select all

$username = 'smee@foo.com';
$password = 'floob';
$domain = 'ftp.foo.com';

echo rawurlencode($username).':'.rawurlencode($password).'@'.$domain;
outputs

Code: Select all

smee%40foo.com:floob@ftp.foo.com

Thanks

Posted: Fri Sep 23, 2005 10:22 am
by murph2481
I will have to try that. I just took over their site this week and they are all straight HTML so I have to move their pages over to PHP. After that conversion takes place I will try it.

Thank You!
Dan