473,461 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using Server.Urlencode

Hi All

I have users who upload files using my application using ASPUPLOAD
component.

My code uploads the file to a network location and once the upload is finish
I display the hyperlink using the following code

<a href=\myserver\attachments\<%=server.urlencode(rs( "FileName"))%>
target="_blank" ><%=rs("Filename")%>

Sometimes the hyperlinks works but sometimes it doesn't.

Should I be using server.urlencode or not.

The problem is my users upload files with all sorts of filename slike
088-888 24(05)-774448.doc which includes spaces, special characters etc.

Can someone offer any help?

Regards
Jul 22 '05 #1
3 7621
"JP SIngh" <no**@none.com> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
I display the hyperlink using the following code

<a href=\myserver\attachments\<%=server.urlencode(rs( "FileName"))%>
target="_blank" ><%=rs("Filename")%>

Sometimes the hyperlinks works but sometimes it doesn't.
You need quotes around attribute values that mightcontain spaces,
as in

<a href="\myserver\attachments\<%=Server.URLEncode(rs ("FileName"))%>"
target="_blank" ><%=rs("Filename")%></a>
Should I be using server.urlencode or not.


Probably and, if only for clarity, I'd prefer to see

<a href="<%= Server.URLEncode( "/myserver/attachments/" & rs("FileName") )
%>" target="_blank" >
<%= Server.HTMLEncode( rs("Filename") ) %>
</a>

HTH,
Phill W.
Jul 22 '05 #2
JP SIngh wrote:
Hi All

I have users who upload files using my application using ASPUPLOAD
component.

My code uploads the file to a network location and once the upload is
finish I display the hyperlink using the following code

<a href=\myserver\attachments\<%=server.urlencode(rs( "FileName"))%>
Why are you using backslashes in your href ? And why aren't you delimiting
the href value?
target="_blank" ><%=rs("Filename")%>

Sometimes the hyperlinks works but sometimes it doesn't.
Please try to describe your symptoms without using the words "doesn't work".

Should I be using server.urlencode or not.

The problem is my users upload files with all sorts of filename slike
088-888 24(05)-774448.doc which includes spaces, special characters
etc.

So show us what the link looks like when you View Source in the browser.

When I try your example like this:
<a href=images/<%=server.urlencode("088-888 24(05)-774448.doc")%>
target="_blank" ><%="088-888 24(05)-774448.doc"%>
I get source that looks like this:
<a href=images/088%2D888+24%2805%29%2D774448%2Edoc
target="_blank" >088-888 24(05)-774448.doc

which yields this url:
http://webdev/test/images/088%2D888+...2D774448%2Edoc

This link will produce a Page Not Found. If I change the href to
<a href="images/<%="088-888 24(05)-774448.doc"%>"
target="_blank" ><%="088-888 24(05)-774448.doc"%>

I get a link that does open my test document.

So the quick answer is:
use the correct slashes in the url
don't use urlencode
delimit the href value

Now, if the link includes a querystring, the answer will change. The
querystring portion of the url will probably need to be urlencoded. Just the
part after the question mark.

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 22 '05 #3

"JP SIngh" <no**@none.com> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
Hi All

I have users who upload files using my application using ASPUPLOAD
component.

My code uploads the file to a network location and once the upload is finish
I display the hyperlink using the following code

<a href=\myserver\attachments\<%=server.urlencode(rs( "FileName"))%>
target="_blank" ><%=rs("Filename")%>

Sometimes the hyperlinks works but sometimes it doesn't.

Should I be using server.urlencode or not.

The problem is my users upload files with all sorts of filename slike
088-888 24(05)-774448.doc which includes spaces, special characters etc.

Can someone offer any help?

Regards
=======================
We re-write file names before saving them, replacing any problematic
characters with underscores.
Jul 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Steve | last post by:
Hi All! I wonder if anyone could help me with the underlying logic of a problem I have. At the moment my working pages run like so ---------------------------------------------------------...
5
by: Dave Smithz | last post by:
Hi There, I have a PHP script that sends an email with attachment and works great when provided the path to the file to send. However this file needs to be on the same server as the script. ...
22
by: Fawke101 | last post by:
Hi there, I am having trouble with some data that is ripped from a SQL database and displayed as a hyperlink. The hyperlink inserts the data into a querystring so the next page can read it. ...
3
by: George Hester | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en-us;301464 Look down at the MyPage.asp example. You will see that Microsoft does this: 'Costruct the URL for the current page s = "http://"...
3
by: KathyB | last post by:
Hi, Been reading a LOT about frames, variables, etc. I realize you can NOT use server.transfer with target frames (which are client)... I have a Parent frame containing Left and Right frames....
4
by: Andreas Klemt | last post by:
Hello, is there a difference between System.Web.HttpUtility.UrlEncode and Server.UrlEncode ?
1
by: msn | last post by:
Invalid file name for monitoring: 'E:\inetpub\wwwroot\xxxxxxx\xxxxxxx\Server.UrlEncode("login.aspx'. File names for monitoring must have absolute paths, and no wildcards. ...
1
by: Dario Sala | last post by:
Hi, what's the difference about Asp Server.UrlEncode and the Asp.Net Server.UrlEncode ? In asp: Server.UrlEncode("*") = %2A In Asp.Net: Server.UrlEncode("*") = *
0
by: Tony | last post by:
Hello I have a working code for asp that I want to use now in asp.net. The code is included below. With this code I create a red bar on the bottom of an image, in which I give some comment on...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.