homepage Welcome to WebmasterWorld Guest from 54.196.201.253
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Stupid thing is killing me.. Problem writing to a text file.
ASP writing to text file script
isaaclloyd




msg:948925
 4:01 pm on Apr 25, 2005 (gmt 0)

I wonder if anyone else has this problem. When I write like over 700 characters to a text file using ASP script, it replaces the first 10 or so characters with this:

Here is my save.asp script:

[b]

<%

Dim objFSO, objFile, data

data = Request.Form("data")

Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("test.txt", ForWriting)
objFile.Write data
objFile.Close
SET objFSO = NOTHING
SET data = NOTHING
SET objFile = NOTHING

%>

[/b]

and here is my write.asp script:

[b]

<%

Dim objFSO, objFile, data, objReadFile, strContents

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("test.txt")
If objFile.Size > 0 Then
Set objReadFile = objFSO.OpenTextFile("test.txt", 1)
strContents = objReadFile.ReadAll
response.write strContents
objReadFile.Close
Else
response.write "The file is empty."
End If

%>

<FORM ACTION="save.asp" METHOD="POST" TITLE="form">

<TEXTAREA NAME="data" ROWS="10" COLS="50">
</TEXTAREA>
<BR>
<INPUT TYPE="submit" VALUE="Submit">

</FORM>

[/b]

the write.asp shows whats on the page, and has a text area to write and save the new text. Comments or suggestions is greatly apreciated. And if anyone has a script for writing to a text file using .php or perl I would greatly apreciate an idea on how to do that. Thanks.

~Isaac Lloyd~

p.s. the [ code ] thing isn't working so my script is in BOLD.

 

mrMister




msg:948926
 12:01 pm on May 5, 2005 (gmt 0)

Try specifying all of the parameters in your openfile method call. Don'y use the defaults.

Try both with ASCII and if you still get the same problem, try with unicode.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved