Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing a TXT file on a server - simple question! 1

Status
Not open for further replies.

fillup07

Vendor
Apr 1, 2002
62
US
Alright, I need to know how to write to a simple .txt file on the server. I tried using this code:
<%
Set FS=Server.CreateObject(&quot;Scripting.FileSystemObject&quot;)
Set RS=FS.OpenTextFile(Server.MapPath (&quot;counter.txt&quot;), 1, False)
fcount=RS.ReadLine
RS.Close
fcount=fcount+1
Set RS=FS.OpenTextFile(Server.MapPath(&quot;counter.txt&quot;), 2, False)
RS.Write fcount
RS.Close
Set RS=Nothing
Set FS=Nothing
%>
<p>This page has been visited <%=fcount%>
times.</p>

To make a hit counter, but I get this error:
Microsoft VBScript runtime error '800a0046'
Permission denied
/asp/philly/counter.asp, line 9

Line 9 is:
Set RS=FS.OpenTextFile(Server.MapPath(&quot;counter.txt&quot;), 2, False)

Now, you may be thinking &quot;it's just his server, there's nothing he can do, because his server doesn't allow anythign to write to it&quot;. I know this isn't true because I made a guestbook using Frontpage and the webbot thing. So, I know I can write to the server.... I just can't figure out how to do it in ASP!

HELPPPP me please!!

fillup07@hotmail.com -Phil
fillup07@hotmail.com
 
When frontpage extensions are installed (which allow you to use the web-bot things) they automatically set the required permissions for writing these files... however this does not help you with permissions required by ASP pages. When you try to write to a file what actually happens is the IUSR_MACHINENAME user writes to that file - if that user does not have permission to write (and it will not by default) to that directory then you will get the access denied error. The only way you will get this problem resolved is to have the hosting company change permissions to allow the IUSR to write to your directory (or to that specific file).
 
Thanks AdmanOK.

One more thing, if I have an ASP file that is supposed to write to a text file, which needs to have permissions? The TXT file, or the ASP file? And what permission does it need (read/write/administer?)? -Phil
fillup07@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top