Hi, I'm a bit rusty in PHP so, in the middle of refreshing concepts, I'm doing a form to upload images to a BD (the name and the path, really) and then, if that image is in the folder of the server specified in the route, show it on the screen.
The code that performs the data insertion is this:
if ($_POST['enviar']) {
$nombre = $_REQUEST['nombre'];
$nombrer = strtolower($_REQUEST['nombre']);
$origen= $_FILES['foto']['tmp_name'];
$destino = "img/" . $nombrer . ".jpg";
copy ($origen,$destino);
$subida = mysqli_query($conexion,"INSERT INTO imagenes VALUES ('". $nombre ."','" . $destino . "')");
if (@mysqli_query($conexion,$subida)) {
echo "La foto se ha subido con éxito";
}
The insertion of data in the table is done correctly, the problem I am having when copying the file that I upload, the image, to the folder / img of the server. As far as I remember, that was done using the copy function, which passed as parameters the source URL in / tmp and the destination URL.
I have tried to print the result of the variable $ origin and it returns a type path:
C:\xampp\tmp\php719F.tmp
By accessing that folder I find that this file does not exist ... Could that be the basis of the problem?