$photo_post_id = $photo_post; //==================================================// //= * COPY FOLDER AVATAR / * =// //==================================================// if (file_exists($path . $photo_post) && isset($photo_post_id)) { copy($path . $photo_post, $path_bg . $photo_post); unlink($path . $photo_post); } //<--- IF FILE EXISTS #2 //<<<-- Delete old image -->>>/ if (file_exists($bg_old) && $infoUser->bg != '' && !in_array($infoUser->bg, $defaults)) { unlink($bg_old); } //<--- IF FILE EXISTS #1 //<<<--- * UPDATE DB * -->>> $obj->updateTheme($photo_post_id); echo json_encode(array('output' => '', 'error' => 0, 'photo' => $photo_post)); } else { echo json_encode(array('output' => $_SESSION['LANG']['error'], 'error' => 1)); } } else { echo json_encode(array('output' => $_SESSION['LANG']['max_size_2'], 'error' => 1)); } } else { echo json_encode(array('output' => $_SESSION['LANG']['formats_available'], 'error' => 1)); } } else { echo json_encode(array('output' => $_SESSION['LANG']['please_select_image'], 'error' => 1)); exit; } }