0
I need it to be inserted into the Mysql Database (table fotos
) the path that is defined as $target_file_name
. I believe the mistake is probably at the moment of INSERT
.
Filing cabinet conexao.php
:
try {
$PDO = new PDO($dsn, $usuario, $senha);
// echo "SUCESSO";
} catch (PDOException $erro) {
//echo "ERRO: " .$erro.getMessage();
// echo "conexao_erro";
exit;
}
?>
Filing cabinet upload_image.php
:
<?php
include "conexao.php";
$target_dir = "upload/";
$target_file_name = $target_dir .basename($_FILES["file"]["name"]);
$response = array();
if (isset($_FILES["file"]))
{
if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file_name))
{
$success = true;
$message = "Sucesso !";
$sql_insert = "INSERT FROM fotos (foto_url) VALUES (:TARGET_FILE_NAME)";
$stmt = $PDO ->prepare($sql_insert);
$stmt -> bindParam(':TARGET_FILE_NAME', $target_file_name);
$stmt -> execute();
}
else
{
$success = false;
$message = "Erro no upload !";
}
}
else
{
$success = false;
$message = "Favor inserir arquivo !";
}
$response["success"] = $success;
$response["message"] = $message;
echo json_encode($response);
?>
You said the mistake is probably at the time of
INSERT
. But where is theINSERT
in the code?– Luiz Felipe
Sorry I was making a mistake and I took it out
– Ronaldo Amaral
and the form, ta as?
– goio
It is sent via Android the code is right is uploading and sending to folder, I just need to take this variable and insert in the bank
– Ronaldo Amaral
It follows updated code, it is taking the image of the ANDROID camera and inserting it into the UPLOAD folder OK ! I need him to insert in the comic book the way in case the variable.
– Ronaldo Amaral
INSERT FROM??? Wouldn’t be INSERT INTO?
– Jorge.M
Puts kkk was exactly that, I gave too soft I ended up not realizing now already this OK !
– Ronaldo Amaral