Write to File: Flash to Server Side interaction

Write to File: ASP
<%
'decalare needed variables
Dim fso, file, name, email, i
'Get data from variables coming from flash
name = Request("userName")
email = Request("userEmail")
'sets variable fso equal to a file system object
set fso = Server.CreateObject("Scripting.FileSystemObject")
On Error Resume Next
'Check to see if the text file already exists
if fs.FileExists("emails.txt") = true then
On Error Resume Next
'If file already exists then open the text file for editing
Set File = fso.OpenTextFile(Server.MapPath("emails.txt"), 8, 0)
On Error Resume Next
'add the variable name to the text file
file.writeline name
On Error Resume Next
'add variable email to the next line of the text file
file.writeline email
On Error Resume Next
'add a blank line to text file. Number indicates number of blank lines to add.
file.writeblanklines(1)
On Error Resume Next
'close object
file.close
On Error Resume Next
else
'if file does NOT exist, create it
Set file = fso.CreateTextFile(FlastText.txt, true)
On Error Resume Next
'add the variable name to the text file
file.writeline name
On Error Resume Next
'add variable email to the next line of the text file
file.writeline email
On Error Resume Next
'add a blank line to text file. Number indicates number of blank lines to add.
file.writeblanklines(1)
On Error Resume Next
'close object
file.close
On Error Resume Next
end if
'If any errors were encounter then run this code
If Err.Number <> 0 then
'tells flash ASP failed and terminates the ASP file.
Response.Write "&server_mes=fail"
Response.End
else
'Send message back to flash saying everything was ok.
Response.Write "&server_mes=success"
End if
'set fso object equal to nothing
set fso = nothing
%>
BYE!
Spread The Word
Attachments
10 Responses to "Write to File: Flash to Server Side interaction" 
|
said this on 10 Apr 2007 10:59:20 PM CST
Great tutorial which help
if &# I changed if (!email_tx.t And then it |
|
said this on 26 Apr 2007 6:23:28 AM CST
nice and simple code. eas
Tha |
|
said this on 09 May 2007 3:39:57 AM CST
hi, i am the beginner and
Although ActionScri i placed the f i think the hardest I would be |
|
said this on 09 Jul 2007 4:16:24 PM CST
Hi,
I think I am havin |
|
said this on 22 Oct 2008 12:51:41 PM CST
Did you ever get past the
|
|
said this on 24 Jul 2007 5:04:31 AM CST
::- Bingo -::
i got |
|
said this on 03 Jan 2008 4:30:21 AM CST
looks good, but I can'
Where is it? |
|
said this on 19 Jan 2008 5:33:04 AM CST
yeah, this looks as if it
|
|
said this on 16 Sep 2008 3:17:09 AM CST
Hi, excellent article - t
Can you confi I understand Many thanks, Dan. |
|
said this on 16 Nov 2009 2:18:09 AM CST
Just a note to people usi
|



Author/Admin)