I have a problem I do not know if it is when sending in $ .ajax or catching with PHP.
It is not getting the $_FILES
normal on the other side, it arrives as 'caminhofoto' => string 'C:\fakepath.jpg' (length=17)
, gave var_dump($_POST)
, however when trying to get the path and move to the directory it only mounts the path but does not get the file. p>
My JS:
var caminhofoto = $("input[name='caminhofoto']").val();
$.ajax({
url: '/add-data.php',
type: 'POST',
data: {
caminhofoto: caminhofoto
}
}).done(function (data) {
console.log("Sucesso: " + data);
});
And in PHP:
$img = "imgs/";
$caminhofoto = $img . basename($_FILES['caminhofoto']['name']);
$imgFileType = strtolower(pathinfo($caminhofoto, PATHINFO_EXTENSION));
$uploaddir = '/fotos/';
$obj->setPath($uploaddir . $caminhofoto );
Only you're saving only the path in the database without the file, it looks like it's going to fakepath it's not catching.