2
Guys I’m trying to save (upload) an image in a directory of Hostinger, but I can’t do it.
Below follows me PHP script.
Obs.: The image in Base64 is coming from an Android app.
<?php
$ftp_server = "ftp.endereço.server";
$ftp_user = "*****";
$ftp_pass = "*****";
$imageCodificada = $_POST['imageCodificada'];
//DECODIFICAR IMAGEM
$imageDecodificada = base64_decode($imageCodificada);
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Não foi possível estabelecer conexão com $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Conectado! na $ftp_user@$ftp_server\n";
file_put_contents(include($_SERVER['DOCUMENT_ROOT']."/public_html/imagens/fotos_func/TESTE.jpg"), imageDecodificada);
} else {
echo "Não foi possível estabelecer conexão com $ftp_user\n";
}
// close the connection
ftp_close($conn_id);
?>
My PHP Script does not give error, but the file does not appear in the directory.
Could someone help me in how to do this.
Thank you.
You have permissions to create a file there?
– Jorge B.
Jorge, thanks for the return. I created a Permit for this. If I did it correctly I have access yes, so much so that in my script echo comes out with "Connected!"... the problem is that the file does not write.
– Thiago Melo