Jump to content

Archived

This topic is now archived and is closed to further replies.

JustinMs66@hotmail.com

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

Recommended Posts

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.com/uploads/number")

dosn't work, because it just take the first word if it has spaces. it does:
"http://www.csscobalt.com/uploads/number"
instead of
"http://www.csscobalt.com/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:
[url=http://www.csscobalt.com/uploads/upload_php.txt]http://www.csscobalt.com/uploads/upload_php.txt[/url]

how can i fix this?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
urlencode() the filename before adding it to the url, then use htmlentities() when echoing to output:

[code]<?php

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

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

?>[/code]

Share this post


Link to post
Share on other sites
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:
[code]<?php
        " has been uploaded. here is the link to your Image: <a href=uploads/".  basename( $_FILES['uploadedfile']['name']). ">".  basename( $_FILES['uploadedfile']['name'])."</a>?>[/code]
to
[code]<?php
        " has been uploaded. here is the link to your Image: <a href='uploads/".  basename( $_FILES['uploadedfile']['name']). "'>".  basename( $_FILES['uploadedfile']['name'])."</a>?>[/code]


Ken

Share this post


Link to post
Share on other sites

×

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.