SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: PHP URL Trouble

  1. #1
    SitePoint Addict
    Join Date
    Aug 2009
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP URL Trouble

    Hi Chaps,

    I have a PHP FTP App, where users can log in using a unique code and a password.

    Their unique code corresponds to an FTP folder, e.g.
    \FTP_Root\Customer A & Co\
    So when the user logs in, they can see their FTP directory and contents, in this case an Inbox and an Outbox.
    This works as the FTP folder contains both an Inbox and an Outbox.

    The problem I am having is when I try browsing within this directory (say the Inbox), ftp-chdir fails.

    I have a hyperlink that sends a 'dir' parameter to the same ftp.php page, and if set, will attempt to change to the given directory.

    So even though the URL Hyperlink reads:
    ....server.co.uk/ftp.php?dir=/FTP_Root/Customer A & Co/Inbox
    When you click on this link, the page tries to load:
    ....server.co.uk/ftp.php?dir=/FTP_Root/Customer A
    So my question is what do I need to change, the Hyperlink to read something like:
    ....server.co.uk/ftp.php?dir=/FTP_Root/Customer%20A%20&%20Co/Inbox
    Do something to the ftp-chdir function, where I encode/decode/whatever to make sure it tries to change to the correct FTP directory?

    Or exclude all ampersand entirely?

  2. #2
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure that "&" is encoded in hex (&=%26), you can use urlencode or rawurlencode to encode query parameters.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •