Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 12th, 2007, 11:32 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default whitespace & querystring

I have an asp page that lists files held on the server like this:
http://p2p.wrox.com/topic.asp?TOPIC_ID=57287

I have recently modified it so I can rename or delete files from the server with a links like this:

<TD align=right>
<%= "<a href=deletefile.asp?filename="& objFileItem.Name & "&foldername=" & foldername & "&path=" & strPhysicalPath & "&username=" & username & "&company=" &company & ">" & "Delete" & "</a>" %>
</TD>

<TD align=right>
<%= "<a href=amendfilename.asp?foldername=" & foldername & "&filename=" & objFileItem.Name & "&path=" & strPhysicalPath & ">" & "Rename" & "</a>" %>
</TD>


My code works fine where the filename does NOT contain whitespace but where the filename includes whitespace the full filename is not passed, only the first part of the file name e.g. 'dictionary.jpg' is passed where 'dic tionary.jpg' only 'dic' is passed to my delete code which is given below.

Filetodelete=(path) & "/" & filename

Set fs=Server.CreateObject("Scripting.FileSystemObject ")

if fs.FileExists(Filetodelete) then
   fs.DeleteFile (Filetodelete)
end if

Set fs=nothing

I know it's something to do with whitespace signifying the end of the query but not sure exactly how I can work around, maybe when uploading files to server delete whitespace?? Not sure, but I cant trust other users to refrain from using whitespace in filenames.

Hope I've explained myself correctly and any help much appreciated.


  #2 (permalink)  
Old May 12th, 2007, 02:23 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

you will probably want to use URLEncode on the file name, it will transform the blank space into %20 and wont cause the problem you are describing:

http://www.w3schools.com/asp/met_urlencode.asp

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
  #3 (permalink)  
Old May 13th, 2007, 03:36 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks I have just done a bit of reading and found the ref you have posted. Is now working as required.



Similar Threads
Thread Thread Starter Forum Replies Last Post
In IE6 How do you get Whitespace??? David P. Manning CSS Cascading Style Sheets 0 April 24th, 2007 08:01 AM
Querystring problem due to & symbol ramuis78 ASP.NET 1.0 and 1.1 Basics 10 September 18th, 2006 12:05 PM
Passing a querystring value that contains '&' jfrizelle Classic ASP Databases 3 March 20th, 2006 09:27 PM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.