JustinMs66@hotmail.com Posted September 12, 2006 Share Posted September 12, 2006 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? Quote Link to comment Share on other sites More sharing options...
PigsHidePies Posted September 12, 2006 Share Posted September 12, 2006 The link to your php code is not currently working. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 12, 2006 Share Posted September 12, 2006 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 Quote Link to comment Share on other sites More sharing options...
Jenk Posted September 12, 2006 Share Posted September 12, 2006 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] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 12, 2006 Share Posted September 12, 2006 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 Quote Link to comment Share on other sites More sharing options...
JustinMs66@hotmail.com Posted September 12, 2006 Author Share Posted September 12, 2006 ok that worked. thnx ken!:D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.