PDA

View Full Version : Problems writing a file..."permission denied"


mattboy_slim
04-14-2005, 08:57 PM
I'm trying to use a web-based form to create config files, and I'm having an issue while creating the files themselves.

Here is the error message:
--------------
Microsoft VBScript runtime error '800a0046'
Permission denied
/writeconfig/configwrite.asp, line 25
--------------

I gave the IUSR_machinename full control over the directory where the files reside.

Here is my code that writes the file: (Line 25 is the final line: set file = fso.OpenTextFile)


'DEFINE THE NAME OF THE TEXT FILE WE WANT TO CREATE
'THEN SET UP THE STANDARD CONSTANTS FOR READING WRITING ETC.

strFileName = request.form("ntpserver")
Const ForReading = 1, ForWriting = 2, ForAppending = 8

'CREATE OUR FSO AND CREATE THE TEXT FILE
'IF IT DOES NOT ALREADY EXIST.

set fso = server.CreateObject("Scripting.FileSystemObject")
set file = fso.OpenTextFile(strFileName,ForAppending ,true)


My entire code for the pages is here:
http://www.thinix.com/writeconfig/default.txt
http://www.thinix.com/writeconfig/configwrite.txt

I think the issue may lie in the fact that the code doesn't know where to put the file, since I'm not using a server.mappath somewhere, but I'm still flaky on this ASP stuff, and have no idea how or where I'm supposed to use it.

Thanks so much in advance.
Matt

mattboy_slim
04-14-2005, 09:03 PM
I changed one line of code, and now it creates the correct file, but how do I add '.conf' at the end of the filename?
strFileName = server.mappath(request.form("ntpserver"))

mattboy_slim
04-14-2005, 09:12 PM
Got it:
strFileName = server.mappath(request.form("ntpserver") & ".txt")