|
writing files in asp
Okay, here's the problem. When I try to go to the page with the ASP code, it says
Server.MapPath() error 'ASP 0174 : 80004005'
Invalid Path Character(s)
/goldteam/confirm_write.asp, line 9
An invalid '/' or '\' was found in the Path parameter for the MapPath method.
Here's the code:
<% Option Explicit
Dim FileName
FileName = "teachers/" & Request.QueryString("teacher") & "/announcements.txt"
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim FSO
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Dim FilePath
FilePath = Server.MapPath(FileName)
If FSO.FileExists(FilePath) Then
Dim File
Set File = FSO.GetFile(FilePath)
Dim Filesize
Filesize = File.size
Dim Textstream
Set Textstream = File.OpenAsTextStream(ForWriting, TristateUseDefault)
Dim Line
Dim Contents
Contents = Request.QueryString("txtAnnouncements")
TextStream.Write(Contents)
Set TextStream = Nothing
Else
Response.Redirect("file_error.asp?teacher=" & Request.QueryString("teacher"))
End If
Set FSO = Nothing
%>
in the url, it's passed a variable with the ? which i know im doing correctly. the idea is if it's pagename?teacher=bob then the file is supposed to be teachers/bob/announcements.txt which is done on line 3. does anybody know how i can fix the error?
|