I'm having difficulty erasing a file from the file, when I pass a "GET", it deletes all files from the file do I have to pass some variable to identify the file name?
<?php
if(isset($_SERVER['REQUEST_METHOD']) AND $_SERVER['REQUEST_METHOD']=='GET'){
$pasta = 'uploads/photos/';
if(is_dir($pasta)){
$diretorio = dir($pasta);
while($arquivo = $diretorio->read()){
$arquivo = ''.$resphotos['photo'].'';
if(($arquivo!='.')&&($arquivo!='..')){
$id = $arquivo = ''.$resphotos['id'].'';
$del = DB::getConn()->prepare('DELETE FROM 'photos' WHERE 'id'=? LIMIT 1');
return $del->execute(array($id));
unlink($pasta.$arquivo);
echo'<span> o arquivo foi apagado</span>';
}
}
}
$diretorio->close();
}else{
echo'a pasta nao existe';
}
?>