Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 18th Dec 2008, 11:24 PM   #1
Active Warrior
 
Join Date: 2008
Posts: 52
Thanks: 3
Thanked 0 Times in 0 Posts
Default
How to create a file in ASP?
Share on: 
fb share twitter share gplus share more share

I have done some reasearch on how to create files
in ASP and found this script:
<%
thetext="Write this text in the file"

Set fs = CreateObject("Scripting.FileSystemObject")
Set wfile = fs.CreateTextFile("myfile.txt", True)
wfile.Write (thetext)
wfile.close
Set wfile=nothing
Set fs=nothing response.write("Text created")
%>

then I created an asp file containing only this script, named it
"create" and uploaded it on one account on one asp-supporting
free host. Then I tried to open that file using my IE6 browser
and received an error message. Then I checked my file manager
(on that free account) and saw that a new file (''myfile.txt") was
not created. I think I am missing something here. Can anyone,
please, explain to me what should I do in order to create files in ASP?
truckload-of-thoughts is offline  
Unread 19th Dec 2008, 07:41 AM   #2
Active Warrior
 
Join Date: 2008
Posts: 52
Thanks: 3
Thanked 0 Times in 0 Posts
Default
Re: How to create a file in ASP?
Share on: 
fb share twitter share gplus share more share

Are you sure you posted this in the right thread? It seems to me that you were answering some other question, but not mine.
truckload-of-thoughts is offline  
Unread 20th Dec 2008, 12:51 AM   #3
Active Warrior
 
Join Date: 2008
Posts: 52
Thanks: 3
Thanked 0 Times in 0 Posts
Default
Re: How to create a file in ASP?
Share on: 
fb share twitter share gplus share more share

I also tried this script (I took it from here):

<%
dim fs,f
set fs=Server.CreateObject("Scripting.FileSystemObject ")
set f=fs.OpenTextFile(Server.MapPath("testread.txt"),8 ,true)
f.WriteLine("This text will be added to the end of file")
f.Close
set f=Nothing
set fs=Nothing
%>


I copied this script into an asp file that I named "experiment"
(experiment.asp) and placed that file into the main folder on my
free account that I had previously opened on a remote
asp-supported free server.

As far as I understand, since the last parameter in
f=fs.OpenTextFile(Server.MapPath("testread.txt"),8 ,true)
is "true", the new file (testread.txt) must be created in the same
folder. However, after I created experiment.asp and tried to open
it with my web-browser (IE 6), the new file wasn't created.

Instead, I got this message:


Server objecterror 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/experiment.asp, line 5
800401f3

Why is it so?
truckload-of-thoughts is offline  
Unread 20th Dec 2008, 02:33 AM   #4
Banned
 
Join Date: 2008
Posts: 88
Thanks: 0
Thanked 6 Times in 6 Posts
Blog Entries: 1
Default
Re: How to create a file in ASP?
Share on: 
fb share twitter share gplus share more share

I don't really know ASP.
But try to change the folder's permissions.
"CHMOD" the folder to 0777.
and also check if there is any command in ASP to chmod files,
because maybe you need to chmod the new file that created before writing something in it.
ofir is offline  
Unread 20th Dec 2008, 02:54 AM   #5
Active Warrior
 
Join Date: 2008
Posts: 52
Thanks: 3
Thanked 0 Times in 0 Posts
Default
Re: How to create a file in ASP?
Share on: 
fb share twitter share gplus share more share

ofir wrote:
""CHMOD" the folder to 0777.
and also check if there is any command in ASP to chmod files"

- how do I do it?
truckload-of-thoughts is offline  
Unread 20th Dec 2008, 01:55 PM   #6
Warrior Member
 
Join Date: 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Re: How to create a file in ASP?
Share on: 
fb share twitter share gplus share more share

Because of virus threat many servers wont allow you
to use scripting objects like creating files & folders.
which your error seems to indicate.

why not go in for PHP its free and supported by
almost all webhosts and u have a large community
to get u through if any problem should arise
rachusrs2 is offline  
Unread 20th Dec 2008, 11:29 PM   #7
Active Warrior
 
Join Date: 2008
Posts: 52
Thanks: 3
Thanked 0 Times in 0 Posts
Default
Re: How to create a file in ASP?
Share on: 
fb share twitter share gplus share more share

Thanks for telling me that - finally I know the reason.
truckload-of-thoughts is offline  
Unread 21st Dec 2008, 06:38 AM   #8
Active Warrior
 
Join Date: 2008
Posts: 52
Thanks: 3
Thanked 0 Times in 0 Posts
Default
Re: How to create a file in ASP?
Share on: 
fb share twitter share gplus share more share

Originally Posted by rachusrs2 View Post

why not go in for PHP its free and supported by
almost all webhosts and u have a large community
to get u through if any problem should arise
Well, I tried doing it in PHP before (click on the name of this thread
in order to see it:
"Is there any web-page copying command in PHP" ), but I
stumbled on a similar problem: the allow_url_fopen is not allowed on
free PHP servers.
truckload-of-thoughts is offline  
Closed Thread


Bookmarks

Tags
asp, create, file


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 10:05 AM.