I'm sending an image to a folder and saving only its path in the database. If for example the name that I attribute the image does not have accents works perfectly, only when it has accents does not work. By saving to the database and showing on the website shows everything correct.
When I save to the folder, I can not fetch its image because the path is for example "Products / zé" and the name appears inside the z & A
Shipping code for database and folder:
if(isset($_POST['upload']) && isset($_FILES['file-image'])) {
$filetmp = mysqli_real_escape_string($_FILES["file-image"]["tmp_name"]);
$filename = mysqli_real_escape_string($dbc, $_FILES["file-image"]["name"]);
$filetype = mysqli_real_escape_string($dbc, $_FILES["file-image"]["type"]);
$ProdName = mysqli_real_escape_string($dbc, $_POST['nameProduct']);
$ProdPrice = mysqli_real_escape_string($dbc, $_POST['productPrice']);
$ProdDescr = mysqli_real_escape_string($dbc, $_POST['descrProduct']);
$filepath = "Products/" . $ProdName ;
$info = getimagesize($filetmp);
if ($info == FALSE or (empty($ProdName) or empty($ProdPrice) or empty($ProdDescr))) {
alertError();
}elseif ($info == FALSE and (empty($ProdName) or empty($ProdPrice) or empty($ProdDescr))) {
alertError();
}elseif ($info == TRUE and (empty($ProdName) or empty($ProdPrice) or empty($ProdDescr))) {
alertError();
}elseif ($info == TRUE and (!(empty($ProdName) or empty($ProdPrice) or empty($ProdDescr)))) {
move_uploaded_file($filetmp, $filepath);
$result = mysqli_query($dbc, "INSERT INTO images (img_name,img_path,img_type) Values('$ProdName','$filepath','$filetype')") or die(errorAdmin());
$last_id = $dbc->insert_id;
$insertProduct = mysqli_query($dbc, "INSERT INTO products (name_Product,prod_description,prod_price,img_id)
Values('$ProdName','$ProdDescr','$ProdPrice','$last_id')") or die(errorAdmin());
mysqli_query($dbc, "SET NAMES 'utf8'") or die(mysqli_error($dbc));
if ($insertProduct == TRUE and $result == TRUE) {
?>
<script type="text/javascript">
swal({
title: 'Good Job',
text: 'Produto Criado Com Sucesso',
type: 'success',
confirmButtonText: 'Feito'
});
</script>
<?php
}
}
mysqli_close($dbc);
}