Error writing text file with PWS - Permissions pro

Results 1 to 3 of 3

Thread: Error writing text file with PWS - Permissions pro

  1. #1
    Gary P Guest

    Default Error writing text file with PWS - Permissions pro

    I am trying to write out a text box from a form to a text file on the server. (Basically a forms-based HTML editor). I am using PWS. I am getting the following error. I suspect that PWS doesn&#039t have permissions to create/write files, but nowhere in the admin interface do I see how to set write permissions (I&#039ve checked &#039Script&#039, &#039Read&#039, and &#039Execute&#039 already). Can this be done with PWS, or do I need IIS? How?<BR><BR>Here&#039s the code snippet:<BR><BR>Set fs = Server.CreateObject("Scripting.FileSystemObject")< BR>textStream = fs.CreateTextFile(Server.MapPath(sSaveToFilePath), true)<BR>&#039Error from above line:<BR>&#039 Object doesn&#039t support this property or method<BR>textStream.Write(Request.Form("UploadDoc ument"))<BR>textStream.Close()<BR><BR><BR>Thanks!

  2. #2
    Gary P Guest

    Default RE: Error writing text file with PWS - Permissions

    Solved my own problem, with the help of a post from last year on 15 second&#039s message board (thanks Manfred Stanfield!). For the benefit of others who may have the problem in the future, here&#039s the answer.<BR><BR>The same object you use the CreateTextFile can&#039t then be used to .Write to that file. The ojbect must be closed, then reopened For Writing. Not sure why, but it works. Here&#039s the working code that does what the above should have done...<BR>Hope this helps someone else out there!<BR><BR>&#060;%<BR>dim fs, sSaveToFile, textStream<BR>Const ForReading = 1, ForWriting = 2, ForAppending = 8<BR><BR>Set fs = Server.CreateObject("Scripting.FileSystemObject")< BR>sSaveToFile = Server.MapPath(Request.Form("SaveToURL"))<BR><BR>I f NOT (fs.FileExists(sSaveToFile)) Then<BR> &#039 Doesn&#039t exist, creating file<BR> Set objCreateFile = fs.CreateTextFile(sSaveToFile, True)<BR> &#039---If you don&#039t close the objCreateFile Object,<BR> &#039---then you get an error if another FileSystemObject<BR> &#039---tries to write to the file.<BR> objCreateFile.Close<BR> Set objCreateFile = nothing<BR>End If<BR><BR>Set textStream = fs.OpenTextFile(sSaveToFile, ForWriting, True)<BR>textStream.Write(Request.Form("HTMLText") )<BR>textStream.Close()<BR>Set textStream = nothing<BR>%&#062;<BR>

  3. #3
    Manoj Guest

    Default RE: Error writing text file with PWS - Permissions

    Are you trying to display the source code of a Asp/Html file ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts