Write to File: Flash to Server Side interaction

Write to File: ASP
Joshua Musselwhite
Skills: Actionscript 1-3, PHP, mySQL, XML, HTML, CSS, Javascript
Portfolio
Availability: Always
<%
'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
7 Responses to "Write to File: Flash to Server Side interaction" 
|
said this on 10 Apr 2007 10:59:20 PM CDT
Great tutorial which helped me a lot! One thing I had to change was
if (!email_txt.length || email_txt.indexOf("@") I changed to if (!email_tx.textt.length || email_txt.text.indexOf("@") And then it worked great. Many thanks,! |
|
said this on 26 Apr 2007 6:23:28 AM CDT
nice and simple code. easy to understand. good tutorial for beginners. just add a line feed at the end so they are neatly written in each line.
Thanks |
|
said this on 09 May 2007 3:39:57 AM CDT
hi, i am the beginner and being the honest it's not really clear for me.
Although ActionScript code is very clear, the same as writeToFile.php file's content, it's still not said how can you test the project, i mean where exactly to put the files from your tutorial. i placed the files on server and it didnt work, it didn't work on localhost as well. do i need any special software for testing it ? i think the hardest part for the beginners is not the code understanding (as it's very clear), but informations about how to test the files . I would be very grateful if you can guide me somehow or recommend some good book. thank you :) |
|
said this on 09 Jul 2007 4:16:24 PM CDT
Hi,
I think I am having the same problem. I tried putting that under my applications folder or desktop. It keeps saying save failed. I put some debug line like msgbox in the asp page but nothing being called. I am a very beginner here (I have experience in c++ and vb)...I am kind of confused. |
|
said this on 24 Jul 2007 5:04:31 AM CDT
::- Bingo -::
i got what i searched for !!!!will be seeking for ur help !!! stay TUNNED !!! cheers |
|
said this on 03 Jan 2008 4:30:21 AM CDT
looks good, but I can't find the source file!
Where is it? |
|
said this on 19 Jan 2008 5:33:04 AM CDT
yeah, this looks as if its just what I've been searching for. But I also cannot find the source. Guess I'll have to work around it.
|



Author/Admin)