Hi,
I hope this list is still running - I haven't received anything in a few days now.
I am new to Drupal and am struggling to work out when I should use drupal_urlencode() and when I should use urlencode(). And is there a urldecode()? I cant find one.
The exact problem I have has to do with putting a filename into a URL as a request parameter. This was being put into a URL without any encoding and worked fine until someone added a file with an & in the name. So I looked into drupal_urlencode(), but it seems to not work, while urlencode() works perfectly.
When I use drupal_encode():
---------------------------
$filename = 'Arm&Hammer.jpg';
$req_param = drupal_urlencode($filename)
The URL for the link produced is:
http://www.xyz.com/download.php?filename=Arm%2526Hammer.jpg
And when I extract the parameter in download.php and use it I get the following error message:
warning: fopen(C:\Program Files\Apache Software Foundation\Apache2.2\drupal_files/images/Arm%26Hammer.jpg) [function.fopen]: failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\download.php on line 10.
When I use urlencode():
-----------------------
$req_param = urlencode($filename)
http://www.xyz.com/download.php?filename=Arm%26Hammer.jpg
download.php is able to extract the request parameter and open the file.
Can someone please explain to me when I should be using drupal_urlencode() and when I should use urlencode().
Thank you
robin