I have a form where you can upload and delete images that are stored in a folder that is at a higher level. This is the route:
- Imagenes_folder / imagen.jpg
- Form_folder / form.html
From form.html I want to delete an image but can not find the path in php. $_POST['archivo']
contains the name of the image, in this example it would be "imagen.jpg"
<?php
$mainRoot = "..//" . "Imagenes_folder//";
if (isset($_POST['archivo'])) {
$archivo = $_POST['archivo'];
$ruta = $mainRoot . basename($archivo);
if (file_exists($ruta)) {
unlink($ruta);
}
}
?>
I do not recognize the route. If I change form.html so that it is on the same level as Imagenes_folder if it works for me:
- Imagenes_folder / imagen.jpg
-
form.html
$mainRoot = "Imagenes_folder//"; if (isset($_POST['archivo'])) { $archivo = $_POST['archivo']; $ruta = $mainRoot . basename($archivo); if (file_exists($ruta)) { unlink($ruta); } }
"..//" This is not the way to go up a level? I have tried with "../" and "../../"