Fix delete of image
This commit is contained in:
parent
db7a98f0ef
commit
dcbad8bb15
@ -288,9 +288,7 @@ if (empty($reshook))
|
|||||||
// Photo save
|
// Photo save
|
||||||
$dir = $conf->societe->dir_output."/contact/".$object->id."/photos";
|
$dir = $conf->societe->dir_output."/contact/".$object->id."/photos";
|
||||||
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
||||||
if ($file_OK)
|
if (GETPOST('deletephoto') && $object->photo)
|
||||||
{
|
|
||||||
if (GETPOST('deletephoto'))
|
|
||||||
{
|
{
|
||||||
$fileimg=$dir.'/'.$object->photo;
|
$fileimg=$dir.'/'.$object->photo;
|
||||||
$dirthumbs=$dir.'/thumbs';
|
$dirthumbs=$dir.'/thumbs';
|
||||||
@ -298,7 +296,8 @@ if (empty($reshook))
|
|||||||
dol_delete_dir_recursive($dirthumbs);
|
dol_delete_dir_recursive($dirthumbs);
|
||||||
$object->photo = '';
|
$object->photo = '';
|
||||||
}
|
}
|
||||||
|
if ($file_OK)
|
||||||
|
{
|
||||||
if (image_format_supported($_FILES['photo']['name']) > 0)
|
if (image_format_supported($_FILES['photo']['name']) > 0)
|
||||||
{
|
{
|
||||||
dol_mkdir($dir);
|
dol_mkdir($dir);
|
||||||
@ -980,7 +979,7 @@ else
|
|||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
}
|
}
|
||||||
print '<table class="nobordernopadding">';
|
print '<table class="nobordernopadding">';
|
||||||
if ($object->photo) print '<tr><td><input type="checkbox" class="flat" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
if ($object->photo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||||
//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||||
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|||||||
@ -567,16 +567,15 @@ if (empty($reshook))
|
|||||||
// Logo/Photo save
|
// Logo/Photo save
|
||||||
$dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
|
$dir = $conf->societe->multidir_output[$object->entity]."/".$object->id."/logos";
|
||||||
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
$file_OK = is_uploaded_file($_FILES['photo']['tmp_name']);
|
||||||
if ($file_OK)
|
if (GETPOST('deletephoto') && $object->photo)
|
||||||
{
|
|
||||||
if (GETPOST('deletephoto'))
|
|
||||||
{
|
{
|
||||||
$fileimg=$dir.'/'.$object->logo;
|
$fileimg=$dir.'/'.$object->logo;
|
||||||
$dirthumbs=$dir.'/thumbs';
|
$dirthumbs=$dir.'/thumbs';
|
||||||
dol_delete_file($fileimg);
|
dol_delete_file($fileimg);
|
||||||
dol_delete_dir_recursive($dirthumbs);
|
dol_delete_dir_recursive($dirthumbs);
|
||||||
}
|
}
|
||||||
|
if ($file_OK)
|
||||||
|
{
|
||||||
if (image_format_supported($_FILES['photo']['name']) > 0)
|
if (image_format_supported($_FILES['photo']['name']) > 0)
|
||||||
{
|
{
|
||||||
dol_mkdir($dir);
|
dol_mkdir($dir);
|
||||||
@ -1837,7 +1836,7 @@ else
|
|||||||
{
|
{
|
||||||
if ($object->logo) print "<br>\n";
|
if ($object->logo) print "<br>\n";
|
||||||
print '<table class="nobordernopadding">';
|
print '<table class="nobordernopadding">';
|
||||||
if ($object->logo) print '<tr><td><input type="checkbox" class="flat" name="deletephoto photodelete" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
if ($object->logo) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> '.$langs->trans("Delete").'<br><br></td></tr>';
|
||||||
//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
|
||||||
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>';
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user