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.