send a string to php


basically again new research myself.

 

what i'm trying do: send out var as2 string, php file write string down txt file (test.txt)

 

i don't know how it, have sample on hand ( upload file local computer server).

 

what i'm trying learn sample how php grab data sending on as2, if can point out part in php file holds name of uploading object.

 

very grateful,

 

as2:

import flash.net.filereference;

 

var fileref:filereference = new filereference();

 

var olistener:object = new object();

 

fileref.addlistener(olistener);

 

olistener.onselect = function(fileref:filereference):void {

    tdata.text = "file name: " + fileref.name;

}

 

 

tbrowse.onpress = function() {  << tbrowse button

    browsefiles();

}

function browsefiles(): void {

    fileref.browse();

}

 

tupload.onpress = function() {

    uploadfile();

}

function uploadfile():void {

    fileref.upload("simplefileupload.php");

}

 

 

 

php code "simplefileupload.php"

 

<?php

 

move_uploaded_file($_files['filedata']['tmp_name'], './'.$_files['filedata']['name']);

 

?>

i have simple fwrite php file, need know goes $somecontent so file name written on test.txt

 

for example, $somecontent = $_files['filedata']['tmp_name'], './'.$_files['filedata']['name']  << it????

 

<?php

$filename = 'test.txt';

$somecontent = "something\n";

 

// let's make sure file exists , writable first.

if (is_writable($filename)) {

 

    // in our example we're opening $filename in append mode.

    // file pointer @ bottom of file hence

    // that's $somecontent go when fwrite() it.

    if (!$handle = fopen($filename, 'a')) {

         echo "cannot open file ($filename)";

         exit;

    }

 

    // write $somecontent our opened file.

    if (fwrite($handle, $somecontent) === false) {

        echo "cannot write file ($filename)";

        exit;

    }

 

    echo "success, wrote ($somecontent) file ($filename)";

 

    fclose($handle);

 

} else {

    echo "the file $filename not writable";

}

?>



More discussions in ActionScript 1 and 2


adobe

Comments

Popular posts from this blog

How to set the order of FAQs instead of alphabetical

Thread: Get UK Keyboard working

how do I change the e-mail address for my merchant account