Advanced Search

Results 1 to 3 of 3

Thread: as2 flash8 + php + write file

  1. #1
    Join Date
    Jun 2008
    Location
    Arganda, Madrid, Spain
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default as2 flash8 + php + write file

    Hello there

    I know that my apache server is working. If I browse my script.php file locally through my browser, my script.php file which is in my pc is run and it writes a test.htm file locally. That is the behaviour I expect. 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:

    Code:
    <?php 
    $fp = fopen("test.htm", "w");
    ob_start();
    echo "&var1=2&"; 
    echo "<html><head><title>The text has been written</title></head><body>Hello</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 suggestion to be able to tell php to write a file from flash 8 as2.
    Thanks a lot.

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Hey...

    Wow, you must be frustrated. I see this mistake a lot but unless you're looking for it, it's easy to miss. Through your testing, you've seen that everything seems to be working independently, just not together.

    The fact is that everything is working. But you're not calling the PHP script via Flash. The tip off? The fact that you're able to get the value of val1 whether your server is on or not. This suggest that the value isn't derived from the server-side script.

    Because you're using the ampersand-separated notation in your PHP script to test for the value of val1, Flash is parsing script.php as a normal text file. For this, it doesn't need server-side script to run.

    To fix this, add an absolute path to your PHP script. If you're testing locally, your absolute URI probably will look something like http://localhost/script.php.

    If you're still confused, I have an example up somewhere. I can hunt it down for you, if you'd like. I believe it's in both ActionScript 2.0 and ActionScript 3.0 (AS3 is a lot more robust to do this in)

  3. #3
    Join Date
    Jun 2008
    Location
    Arganda, Madrid, Spain
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Medyman View Post
    Hey...

    Wow, you must be frustrated. I see this mistake a lot but unless you're looking for it, it's easy to miss. Through your testing, you've seen that everything seems to be working independently, just not together.

    The fact is that everything is working. But you're not calling the PHP script via Flash. The tip off? The fact that you're able to get the value of val1 whether your server is on or not. This suggest that the value isn't derived from the server-side script.

    Because you're using the ampersand-separated notation in your PHP script to test for the value of val1, Flash is parsing script.php as a normal text file. For this, it doesn't need server-side script to run.

    To fix this, add an absolute path to your PHP script. If you're testing locally, your absolute URI probably will look something like http://localhost/script.php.

    If you're still confused, I have an example up somewhere. I can hunt it down for you, if you'd like. I believe it's in both ActionScript 2.0 and ActionScript 3.0 (AS3 is a lot more robust to do this in)
    Thanks a lot for your good and effective reply. For the time being you solved my problem.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •