Jump to content

Post variable from Flash to php


jspodisus

Recommended Posts

Hi all,

 

I've got a flash front end for an image gallery. The images are pulled into

Flash via php which delivers a string of filepaths - this works fine.

 

Now I need to allow users to delete certain images if they choose so I need

to be able to pass a particular filepath to a new php file (delete.php).

 

I have the filepath of the currently displayed image as a variable in flash

called "delete_path".

 

QUESTION - how, (on a button trigger with AS2) can I pass this string "delete_path" to delete.php ?

 

WORTH KNOWING - there is tons of other dynamic data on the flash front end

and I don't really want to chuck it all at the php file - just the one variable "delete_path".

Link to comment
https://forums.phpfreaks.com/topic/181863-post-variable-from-flash-to-php/
Share on other sites

Your need to pass the parameter via a POST or a GET

for example (GET), delete.php?delete_path=123

the PHP would look like this

<?php
$delete_path = $_GET['delete_path'];
//do something with $delete_path

 

for example (POST), the PHP would look like this

<?php
$delete_path = $_POST['delete_path'];
//do something with $delete_path

 

Now my flash skills are.. well not that great! but this should work or at least give you a direction

your button would call an AS that would look like this

GET

var delete_path:string = "123";
getURL("delete.php?delete_path="+delete_path);

 

POST your use LoadVars.send or LoadVars.sendAndLoad

LoadVars.send does a POST (or GET) without opening a browser windows or displaying anything to the user.

LoadVars.sendAndLoad does the same thing while getting a return value from the target script.

userData = new LoadVars();
userData.delete_path = "123";
userData.send("delete.php", 0, "POST");

 

Hope that helps

  • 2 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.