Explorar el Código

fix a bug when uyploading pictures for multi-url

eric hace 9 años
padre
commit
095711398d
Se han modificado 1 ficheros con 4 adiciones y 0 borrados
  1. 4 0
      main/admin/access_url_edit.php

+ 4 - 0
main/admin/access_url_edit.php

@@ -45,6 +45,10 @@ if ($form->validate()) {
                 if ($_FILES[$image_field]['error'] == 0) {
                     // Hardcoded: only PNG files allowed
                     if (end(explode('.', $_FILES[$image_field]['name'])) == 'png') {
+						if(file_exists($url_images_dir.$url_id.'_'.$image_field.'.png')) {
+							// if the file exists, we have to remove it before move_uploaded_file
+							unlink($url_images_dir.$url_id.'_'.$image_field.'.png');
+						}
                         move_uploaded_file(
                             $_FILES[$image_field]['tmp_name'],
                             $url_images_dir.$url_id.'_'.$image_field.'.png'