Jump to content


Photo

Links With Spaces Don't Work!!!! HELP!!! PLZ!!!


  • Please log in to reply
5 replies to this topic

#1 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 12 September 2006 - 05:12 AM

i have a working upload script, but whenever you try to upload anything with a space, the link won't work. i mean, it does work, and if u type it in manually it works, but the link that is echo'd after the upload:

here is the link to your Image: number one.jpg
(and the link for "number one.jpg is: "http://www.csscobalt...uploads/number")

dosn't work, because it just take the first word if it has spaces. it does:
"http://www.csscobalt...uploads/number"
instead of
"http://www.csscobalt.../uploads/number one.jpg"

but the wierd thing, is that the text will say, "here is the link for number one.jpg" and it works their, just not for when it does the link!

anway, here is my PHP code:
http://www.csscobalt.../upload_php.txt

how can i fix this?

#2 PigsHidePies

PigsHidePies
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 12 September 2006 - 05:31 AM

The link to your php code is not currently working.

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 12 September 2006 - 05:32 AM

The page with your source isn't loading for me. Please post the lines of your script that are causing the problem.

Without seeing the code, I'm guessing that you are using a form and in the <input> tags you have value attributes that don't have quoted values.  But that is only a guess.

Ken

#4 Jenk

Jenk
  • Members
  • PipPipPip
  • Advanced Member
  • 778 posts

Posted 12 September 2006 - 08:25 AM

urlencode() the filename before adding it to the url, then use htmlentities() when echoing to output:

<?php

$filename = 'number one.jpg';
$url = 'http://www.example.com/folder/' . urlencode($filename);

echo '<a href="' . htmlentities($url) . '">Link..</a>';

?>


#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 12 September 2006 - 01:57 PM

Now that I've see your code, I can say I was close, but not quite correct. You need to quote the "href"'s. That will automagically do the urlencode() for you.

Change the lines the read:
<?php
        " has been uploaded. here is the link to your Image: <a href=uploads/".  basename( $_FILES['uploadedfile']['name']). ">".  basename( $_FILES['uploadedfile']['name'])."</a>?>
to
<?php
        " has been uploaded. here is the link to your Image: <a href='uploads/".  basename( $_FILES['uploadedfile']['name']). "'>".  basename( $_FILES['uploadedfile']['name'])."</a>?>


Ken

#6 JustinMs66@hotmail.com

JustinMs66@hotmail.com
  • Members
  • PipPipPip
  • Advanced Member
  • 138 posts

Posted 12 September 2006 - 06:18 PM

ok that worked. thnx ken!

:D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users