Jump to content

ftp_login() failure - escaping of special chartacters?


dbrb2

Recommended Posts

Hi,

 

I have an ftp server, with a username of the form:

 

abcd@defg

and a password both alphanumeric and non-alphanumeric characters

 

If I log into the server from the command line (linux),  all is fine

If I try the same credentials using ftp_login(), then I reliably vget authentication failure

 

Does ftp_login need credentials to be escaped in some way?

Link to comment
Share on other sites

$ftp_server="1.2.3.4";

$ftp_user_name="user@host.foo";

$ftp_user_pass="abc@cde*#";

$ftp_port=21;

 

$conn_id = ftp_connect($ftp_server,$ftp_port,30) or die("Couldn't connect");

$login_result = ftp_login ($conn_id,$ftp_user_name,$ftp_user_pass);

print_r($login_result);

ftp_close($conn_id);

 

I have also tried using ftp_raw - I think it may be the @ in the username causing problems. However, my attempts to escape it thus far have failed. For instance, replacing it with '%40' gives:

 

ftp_login(): Syntax error in parameters or arguments

 

Any ideas?

Link to comment
Share on other sites

No - however I have it sorted

I ran wireshark up whilst trying from the command line (OK) and php (not OK)

 

The difference was obvious - the password contained a $ sign, which was being treated as a special character by php. Esacaping it with a \ character, all is now fine!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.