I tried to upload a profile picture using this code in php
y well it saves it in the path that I specify but it doesn't save anything in the database. I am working with wampserver
and phpmyadmin
.
The code I have is the following:
$imagen = $_FILES['imagen']['name'];
$ruta = "../subidos/" . $_FILES['imagen']['name'];
$resultado = @move_uploaded_file($_FILES["imagen"]["tmp_name"], $ruta);
$modificar=("UPDATE usuario SET nombre = '".$nombre."', pass= '".$password."',
escolar = '".$nivel."',nacimiento='".$fecha2."',foto_perfil='".$image."'
WHERE CodUsua='".$_SESSION["CodUsua"]."'");
Your code is fine. From what I can see, the error is in this part
You are typing "$image" and from what I read, your variable is called "$image". Your query should look like this:
And thanks to the collaboration of JackNavaRow, in the future, if you want to show that image to the user or someone else you can use:
Where do you intend to save the profile picture in the database? In the "photo_profile" field?
If so, what I recommend you do in the update is to save the path in that field: $path. So when you go to load from the BBDD the profile picture only in the fetch you just have to put the