I have this PHP code that I'm trying to get to write a file that it receives from a POST form a Java app:
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/www/';
$uploadfile = $uploaddir . basename($_FILES["fileToUpload"]["name"]);
$file_name = "image.jpg";
//move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);
if ($_FILES["fileToUpload"]["error"] > 0)
{
echo "Apologies, an error has occurred.";
echo "Error Code: " . $_FILES["fileToUpload"]["error"];
}
else
{
move_uploaded_file($_FILES["fileToUpload"]["tmp_name"],
"/" . $_FILES["fileToUpload"]["name"]);
echo "Stored in: " . "" . $_FILES["file"]["name"];
}
$handle = fopen($file_name, "w");
fputs($handle, $_FILES["fileToUpload"]["name"]);
fclose($handle);
print_r($_FILES);
?>
The output says that it is saving to Array. How do I get that data from Array to file?
Here is the output from the Java side (client)
Stored in: Array
(
[IMG_1909_jpg] => Array
(
[name] => IMG_1909.jpg
[type] => application/octet-stream
[tmp_name] => C:\wamp\tmp\phpD912.tmp
[error] => 0
[size] => 123231
)
)
Could someone please help? Thanks