Reputation: 6635
I am trying to take a variable sent from flash, and save it to a spot on my web server using PHP, I have NO idea how to do this, and I can't seem to find code that works anywhere on the web, any help would be greatly appreciated, thanx!
Upvotes: 0
Views: 367
Reputation: 6635
I finally got it to work with this code,
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
$im = $GLOBALS["HTTP_RAW_POST_DATA"];
$fp = fopen($_GET['name'], 'wb');
fwrite($fp, $im);
fclose($fp);
echo "result=".$_GET['name'];
} else echo 'result=An error occured.';
Thanx to everyone who posted and helped me to get this working!
Upvotes: 0
Reputation: 6215
Here's an entry I submitted to the Flex Cookbook that addresses your specific question:
http://cookbooks.adobe.com/post_Creating_a__png_file_from_a_webcam_image-12732.html
Should have enough there to let you handle it.
Upvotes: 2
Reputation: 30252
$my_value = $_REQUEST['my_variable_name'];
file_put_contents('path/to/file.jpg', $my_value, FILE_APPEND | LOCK_EX);
I am not sure what you mean by byteArray, anyway if you can treat this as raw data from jpeg, then you can grab it in one go and save it to a file. Actually you can do it with one line of code with
file_put_contents('path/to/file.jpg', $_POST['my_variable_name'], FILE_APPEND | LOCK_EX);
Upvotes: 1