Jump to content

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


JustinMs66@hotmail.com

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?
Link to comment
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
Link to comment
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]
Link to comment
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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.