[WEB4LIB] http head scratcher

Mark Ellis mark.ellis at rpl.richmond.bc.ca
Fri Jun 1 12:24:06 EDT 2001


Mike,

You need to URL encode the links.  Replace spaces in the URLs with "%20" and
it'll work without touching the actual file names. There are other
characters that have special meanings in URLs which also need to be
converted, so it's best to run the file names through a function like this:

sub UrlEncode {

	my($toencode) = @_;
	$toencode=~s/([^a-zA-Z0-9_\-.])/uc sprintf("%%%02x",ord($1))/eg;
	return $toencode;
}

This Perl subroutine is from Lincoln Stein's CGI.pm  There must be something
comparable in VB.

Mark Ellis
Manager, Reference and Information Services
Richmond Public Library  
Richmond, B.C.                      
(604) 231-6410
www.yourlibrary.ca


> -----Original Message-----
> From: Mike Novak [mailto:prx000 at mail.connect.more.net]
> Sent: Friday, June 01, 2001 9:03 AM
> To: Multiple recipients of list
> Subject: [WEB4LIB] http head scratcher
> 
> 
> Greetings folks,
> 
> Our director wanted me to put our policy documents up on a 
> staff intranet
> (basically a web page IP restritricted) so I whipped up a 
> script (using
> VBScript, which I like quite a bit) to create a dynamic page 
> with links to
> the Word documents in a server directory.  The thing was, the 
> file names had
> spaces in them, i.e. "Disruptive behavior.doc".  I wanted to 
> have the page
> created on the fly so she could just dump additional files into the
> directory without my having to add new links to the web page. 
>  We're an NT
> environment running IIS 4.0.  Obviously a URL with a space 
> won't work, so I
> tried converting the space in the URL to a % (i.e.
> "Disruptive%behavior.doc") which seems to work other places 
> but didn't work
> in this case.  Then I tried using the "short name" (i.e. 
> "Disrup~1.doc",
> which is available from a method of the file system object.  
> I figured since
> it was all Microsoft, it should work.  But it didn't!  So 
> finally I settled
> on converting the spaces in the filenames to underscores by hand, then
> having the script display the filename converting the 
> underscore to a space
> and knocking off the extension, creating a nice unordered 
> list.  Anyway, is
> there a way I could have kept the spaces in the filenames and 
> still linked
> to them from the web?  (I wouldn't put spaces in the filenames in the
> firstplace, but that's another story :) )
> 
> Thanks,
> Mike Novak
> Technology Coordinator & Reference Librarian
> University City Public Library
> 


More information about the Web4lib mailing list