From dcbad8bb15cd777a66c4b03e9dc9704c51b9747c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Dec 2015 17:32:20 +0100 Subject: [PATCH] Fix delete of image --- htdocs/contact/card.php | 19 +++++++++---------- htdocs/societe/soc.php | 17 ++++++++--------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php index 1da57afc2f6..d762b134b1c 100644 --- a/htdocs/contact/card.php +++ b/htdocs/contact/card.php @@ -288,17 +288,16 @@ if (empty($reshook)) // Photo save $dir = $conf->societe->dir_output."/contact/".$object->id."/photos"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); + if (GETPOST('deletephoto') && $object->photo) + { + $fileimg=$dir.'/'.$object->photo; + $dirthumbs=$dir.'/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + $object->photo = ''; + } if ($file_OK) { - if (GETPOST('deletephoto')) - { - $fileimg=$dir.'/'.$object->photo; - $dirthumbs=$dir.'/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); - $object->photo = ''; - } - if (image_format_supported($_FILES['photo']['name']) > 0) { dol_mkdir($dir); @@ -980,7 +979,7 @@ else print "
\n"; } print ''; - if ($object->photo) print ''; + if ($object->photo) print ''; //print ''; print ''; print '
'.$langs->trans("Delete").'

'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
'; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b7465abe85b..75e45a9a468 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -567,16 +567,15 @@ if (empty($reshook)) // Logo/Photo save $dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos"; $file_OK = is_uploaded_file($_FILES['photo']['tmp_name']); + if (GETPOST('deletephoto') && $object->photo) + { + $fileimg=$dir.'/'.$object->logo; + $dirthumbs=$dir.'/thumbs'; + dol_delete_file($fileimg); + dol_delete_dir_recursive($dirthumbs); + } if ($file_OK) { - if (GETPOST('deletephoto')) - { - $fileimg=$dir.'/'.$object->logo; - $dirthumbs=$dir.'/thumbs'; - dol_delete_file($fileimg); - dol_delete_dir_recursive($dirthumbs); - } - if (image_format_supported($_FILES['photo']['name']) > 0) { dol_mkdir($dir); @@ -1837,7 +1836,7 @@ else { if ($object->logo) print "
\n"; print ''; - if ($object->logo) print ''; + if ($object->logo) print ''; //print ''; print ''; print '
'.$langs->trans("Delete").'

'.$langs->trans("Delete").'

'.$langs->trans("PhotoFile").'
';