Jump to content

Url Encode A Space


Recommended Posts

Hello,I have some user submitted data that becomes part of a html file name and so in turn will be displayed as a URL across different browsers. I allow the submitted data to contain the URL illegal space character. When I submit it using my Firefox browser the space is automatically encoded to a "+". I'm not sure if this happens with every browser so I'm wondering if I need to encode any space characters before sending them to my server script.Thank you for your time.

Link to post
Share on other sites

I'm sorry I worded my question wrong. What I wanted to ask was:Do you think I need to URL encode space characters as they are illegal in URLs?I figured that I do because if a user submits "user name" it will become part of the html file name like so: user name.html. Of course spaces are illegal in URLs so the address http://www.example.com/userpages/user name.html would return a 404 error.Thank you.

Link to post
Share on other sites

For paths, yes, but for form fields, + is the convention, and all browsers will encode it like that. I'm sure there's a reason somewhere.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...