I got a script (Java android and php) from a book I'm studying that simply takes a photo sent from android and saves it to a folder on my server. Home The android application ran without any error, but I ended up with an error in the file in php:
if ($_FILES["arquivo"]["error"] > 0) {
// Bad Request
http_response_code(400);
} else {
$arquivo_destino = "imagens/" . $_POST["titulo"] . ".jpg";
if (file_exists($arquivo_destino)) {
http_response_code(501);
} else {
move_uploaded_file(
$_FILES["arquivo"]["tmp_name"],
$arquivo_destino
);
http_response_code(200);
}
}
The error happens in the http_response_code(400)
function, searching the net li something saying that this function only works in php 5.4 or higher (not sure if this is true), so I wanted to know if it has any alternative function for my version of php 5.2 .17.
Home
For those who did not understand what I'm trying to do, I'm sending a photo through the android and returning an http code according to what happens there on the server in the php file (if there is an error with the file returns 400, if there is already a file with the same name returns 501, and if all else happens, 200 returns.)