Url encode chars like + & is giving me trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ThaRebel
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 7:56 am

Url encode chars like + & is giving me trouble

Post by ThaRebel »

Hi there,

i have this problem about downloading files with a download.php page.

for example

download.php?file=de + factor.jpg


I was hoping there is a sort of command for this to work, else i need to go over all the chars and rename them or something :(. that might be time consuming...

If anybody got an idea plz.

Btw this is the line-code from the form-page:

Code: Select all

<?php
	echo "    <td width=320 bgcolor=#fee0b2 class=normal><a href="download.php?file=" . $row["SourceFileName"] . "" target=_blank>" . $row["Description"] . "</a></td>\n";
?>

And this is the "redirect" line in download.php:

Code: Select all

<?php
      header('Location: ' . $downloadfile);
?>
Last edited by ThaRebel on Sat Nov 01, 2003 12:56 pm, edited 2 times in total.
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

try urlencode($url);
http://us2.php.net/urlencode
good luck
ThaRebel
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 7:56 am

Post by ThaRebel »

I have tried that, without succes.
ThaRebel
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 7:56 am

Post by ThaRebel »

I need to get rid of those "+" or "&" chars... thats simple.. ahum..
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

try:

Code: Select all

<?php
echo "    <td width=320 bgcolor=#fee0b2 class=normal><a href="download.php?file=" . urlencode($row["SourceFileName"]) . "" target=_blank>" . $row["Description"] . "</a></td>\n"; 
?>
ThaRebel
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 7:56 am

Post by ThaRebel »

i did. outcome same :(
ThaRebel
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 7:56 am

Post by ThaRebel »

Got it solved, rawurldecode.
ThaRebel
Forum Newbie
Posts: 12
Joined: Wed Oct 22, 2003 7:56 am

Post by ThaRebel »

Thnx though for your replies m8! :D
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post by Cruzado_Mainfrm »

:roll: damn, but i was close
Post Reply