The $_FILES superglobal in PHP is an associative array containing details about the uploaded content. AppGameKit uses the key "myfile" to store information about the upload. So, you can retrieve the filename and the PHP temporary filename in PHP using:
$upload_file = basename($_FILES['myfile']['name']);
$upload_file_tmp = $_FILES['myfile']['tmp_name']
(If you are moving the uploaded file to another folder on the server, you can prepend it as needed to the $upload_file variable as long as the indicated directory already exists on the server).
You can then pass the temporary and final file data to the move_uploaded_file function to complete the transfer.
if(move_uploaded_file($upload_file_tmp, $upload_file)) {
echo "1";
} else {
echo "0";
}
For simplicity I echo '1' if successful, '0' if not. This way in AppGameKit you can read the HTTP response and take whatever action depending on if it was successful or not.
A simple working PHP script may look like:
<?php
// If no file has been detected, exit
if(!isset($_FILES['myfile']))
{
echo "0";
exit;
}
// Store original and temporary filename information
$upload_file = $_FILES['myfile']['name'];
$upload_file_tmp = $_FILES['myfile']['tmp_name'];
// Move file to its destination
if (move_uploaded_file($upload_file_tmp, $upload_file)) {
echo "1";
} else {
echo "0";
}
?>
P.S., You can retrieve and store PHP's temporary upload directory if needed for any reason by using something like:
$upload_dir = ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir();