0
I am trying to migrate MYSQL to PDO, and came across a problem with Unlink.
With the code below I can do the UPDATE in the BD Banner table, and also store the new file in the destination folder (img_banner), but not replacing the previous file in the destination folder.
<?php
if(isset($_POST['banner'])){
$codigo = $_GET['codigo'];
$imagem = $_POST['imagem'];
$sqlUpdate = 'UPDATE banner SET imagem = ? WHERE codigo = ?';
$dados = array($imagem, $codigo);
$pasta = '../img_banner/';
if (isset($_POST['banner'])){
$check = @$_POST['apagar'];
foreach($check as $imagem){
$delcheck = $sqlUpdate = 'UPDATE banner SET imagem = ? WHERE codigo = ?' or die (mysql_error());
unlink($pasta.'/'.$imagem);
if ($delcheck >= '1'){
echo 'Imagem deletada com sucesso!';
}else{
echo 'Erro ao deletar imagem, tente novamente!';
}}}}
?>
<?php include 'upload_banner.php'; ?>
<form action="" method="POST" enctype="multipart/form-data">
<input size="1" type="hidden" name="codigo" value="<?php echo $codigo?>" readonly>
<input type="hidden" type="checkbox" name="apagar[]" value="<?php echo $imagem ?>" checked readonly>
<label>Selecione uma nova imagem:</label><br />
<input type="file" name="imagem[]" accept="image/*" ><br />
<input type="submit" name="banner" value="Atualizar">
</form>
With this co I say this presenting me the following errors below:
Error 01:
Notice: Undefined index:imagem in C: wamp www Commerce admin edit_banner__inicial-upd.php on line 41
Error 02:
Notice: unlink(../img_banner//); Permission denied in C: wamp www Commerce admin edit_banner_inicial-upd.php on line 53
Any help will be most welcome.;)