View Full Version : Writing to a text file through FLASH?PHP??
whispers
12-22-2001, 08:42 PM
I would like to know how I can use FLASH to write to a text file and be saved on a server....and then (I think I know this part..unless special circumstances) upon click of a button load this text file into a special dynamic text filed. My main concern is writing to a text file. Probably using PHP since I believe it will be easier (no permissions..etc...) The whole idea is to have two boxes/text fileds...each having a button or two. The top box will have button saying "retrieve"...when he clicks..he will load an external text file into the box (dynamic filed) This will be a text file that I leave for that person...news,...messege...etc....etc.
The second/bottom box will have a button saying "send" that will save the text he enters into the input box/field to a text file on the server....for me to look at later..
The first part I think I can do..unless the text file the php script saves has some weird text in it making it hard to load the specific saved text file.
The second part is what I need help with...I need to know how to use a script (PHP? or CGI??) to gather the text (variable) and save it to a text file???
I know "no" PHP or CGI...How do I make a PHP script..I have some code...but dont know how to edit it for my perpuoses.
I dont know what code to attach to the buttons?..Just the URL/path to the PHP script? How do I make a PHP script?
Anybody can help...I would appreciate it!! Thanks
-whispers-
Jesse
12-23-2001, 04:25 AM
If you search 'php write file server' (or similar) you will find many threads on the subject. Select one with lots of replies as we've discussed this extensively before. Also note that PHP does use file permissions...
whispers
12-23-2001, 04:54 AM
Thanks you..I did not know that PHP files need permissions too! I am new to backend scripting! Do you know what permissions need to be set? I will do a search ! Thanks..I appreciate it! If I need help I will holler! :) Thanks again! -whispers-
whispers
12-23-2001, 07:06 AM
OK..Jesse,...... I have taken a look at the search results...and some thread links too! I threw together a generic movie with two text fileds one to enter text in and save to the text file on the server. The other text filed is just a dynamic filed that will load messages (variables) from another text file (set up to load same one right now!)
I test the movie...the PHP script you posted seems to NOT be working for me! I check the text file (test.txt) and it has no variables/text at all. Just for testing sakes I typed some text in the text file example: get=jhgjhgjhgj
When I try to load this into the dynamic text field..it works fine...the problem is I cant get the PHP file to write anything to the text file. I have it all zipped up if yo uwould like to look at it..or maybe you can help with any ideas you might have off the top of your head! Thanks -whispers-:D
p.s. I am testing in a folder/directory on my desktop..does this make a difference??
Jesse
12-23-2001, 07:31 AM
It will (of course) only work if you are running a PHP compliant server program on your computer. Are you running a webserver with PHP enabled?
As for which permissions need to be set, on your PC you wont need any, but online the PHP file and the directory will need CHMOD 777.
whispers
12-23-2001, 07:49 AM
I installed PHP Triad which has Apache, MySQL..I do not know how tou use it though..Do I need to have the Apache DOS window open or something?..Not sure..all this is foreign to me...just trying to get my feet wet and learn something new! I am just trying to test locally on my computer for right now..until I am sure it works! But like I said.....the PHP script is NOT writing to the text file! Is there something I am missing?...Does there need to be a variable name of the input field (input) somewhere in the PHP script?...Thanks -whispers-
Jesse
12-23-2001, 08:02 AM
I strongly recommend this tutorial: http://hotwired.lycos.com/webmonkey/programming/php/tutorials/tutorial4.html . You will have to ensure PHP is working before you try interacting with Flash. He covers installation of PHP there, but more importantly he shows you how to test if it's working (the PHPInfo file he makes... skip a few pages and find it). If PHP is working, post back here, If it isn't, fix it up (perhaps by following this guide, although it's old) then get back to me...
Jesse
12-23-2001, 08:04 AM
Here's the URL with the info on how to test if PHP is running: http://hotwired.lycos.com/webmonkey/99/21/index2a_page5.html?tw=programming and YES, you will need to make sure Apache is running, as PHP is loaded with that, and generally that means you'll have the DOS prompt open which says "Apaches is running" or the like...
whispers
12-23-2001, 08:16 AM
When I start the Apche Server Program...It is a DOS Promt box..and it has Apache is running........
What do I do from here?...I am going to look at your links right now..just letting you know that Apache does run.....
-whispers-
whispers
12-23-2001, 09:01 AM
I'm sorry..I have no idea what I am doing..I cant seem to get Apache.....and PHP to work on my computer....
I can start Apache..says its running...
I did installer PHP 4.....I have no idea where to go from here....I tried to open up my browser and look at some .php files..no luck
When I type http://localhost it brings up a page about "Welcome to PHPTriad 2.1.1".....an HTML page. I am clueless...Appreciate any help you can give...
-whispers-
Jesse
12-24-2001, 03:45 AM
That localhost bit indicates it is working... Apache at least if not PHP. You need to find the directory which Apache is linking localhost too. In my case it's C:\Apache\httdocs\ . Find that dir and pop a sample PHP file in there (like the PHPInfo file we spoke of before), then go to your browser and enter: http://localhost/filesname.php and if it works, PHP is working...
thosecars82
06-26-2008, 03:32 PM
That localhost bit indicates it is working... Apache at least if not PHP. You need to find the directory which Apache is linking localhost too. In my case it's C:\Apache\httdocs\ . Find that dir and pop a sample PHP file in there (like the PHPInfo file we spoke of before), then go to your browser and enter: http://localhost/filesname.php and if it works, PHP is working...
Hello there
I know this is an old thread but I wish someone can take a glance at it.
I have the same problem with as2 flash8. I know that my php local server is working though. If I browse my php file through my browser, my php scripts is run and it writes a file locally. Nonetheless, this file is not created when I run this flash sentence:
senderLoad.sendAndLoad("script.php",_root.receiveLoad);
On one hand, I have checked that the function receiveLoad.onLoad
is actually called. Moreover, if I do something like
echo "&var=1" in the script.php file, actually, I can check that this value is being passed correctly to flash. However, the script.php file is not writing like it should for writing the test.htm file. The php code is this:
<?php
$fp = fopen("test.htm", "w");
ob_start();
echo "&var1=2&";
echo "<html><head><title>Texto creado</title></head><body>Hola</body></html>";
$html = ob_get_contents();
ob_end_clean();
fwrite($fp, $html);
fclose($fp);
?>
On the other hand, it is strange that not only I get the variable var1 returned to flash correctly when my apache server is working but also when apache is not working.
I would appreciate any solution.
Thanks
whispers
06-26-2008, 04:31 PM
try
senderLoad.sendAndLoad("script.php",_root.receiveLoad, "POST");
sendAndLoad() takes 3 parameters.. last being METHOD I believe..
thosecars82
06-26-2008, 05:01 PM
try
senderLoad.sendAndLoad("script.php",_root.receiveLoad, "POST");
sendAndLoad() takes 3 parameters.. last being METHOD I believe..
Thanks for the quick reply. I have just added the "POST" parameter as you said but it does not make any difference. It still does not seem to create the file.
Let's say your swf file is loaded into nameofyourswf.html and you are viewing that page through your web browser at http://localhost/nameofyourswf.html.
It sounds like you want to dynamically change that html page you are viewing by how the user interacts with your swf file via PHP.
But, actionscript works with PHP covertly.
Meaning you could…
send values to PHP through your swf and PHP then creates an html file behind-the-scenes, not even changing the address in the address bar, but creating the file on the server.
Or
Send values to PHP through your swf file and have PHP send values to back to your swf. Again, the user not even knowing they called the PHP file.
But, tell me which of the two you would like to do and I will post the code for the PHP and the actionscript. Do you want to create an html file on your server when the user activates that through your swf or do you want to change values, text, in your swf with PHP as the user interacts?
thosecars82
06-28-2008, 02:10 PM
Let's say your swf file is loaded into nameofyourswf.html and you are viewing that page through your web browser at http://localhost/nameofyourswf.html.
It sounds like you want to dynamically change that html page you are viewing by how the user interacts with your swf file via PHP.
But, actionscript works with PHP covertly.
Meaning you could…
send values to PHP through your swf and PHP then creates an html file behind-the-scenes, not even changing the address in the address bar, but creating the file on the server.
Or
Send values to PHP through your swf file and have PHP send values to back to your swf. Again, the user not even knowing they called the PHP file.
But, tell me which of the two you would like to do and I will post the code for the PHP and the actionscript. Do you want to create an html file on your server when the user activates that through your swf or do you want to change values, text, in your swf with PHP as the user interacts?
Hello there
I already solved the problem by using a complete (absolute)url instead of a relative one in the call to sendandload(""script.php",....
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.