попробовать ..
if (file_exists ($ target_path) && is_dir ($ target_path)) {// остальная часть кода ...
}
вместо ...
если (! (File_exists ($ target_path))) {
}
Надеюсь, это поможет вам ...
...............................
еще одна вещь ...
Я думаю, что проблема с if (! (file_exists ($ target_path))) {} Заявление,
ЭТО ДОЛЖНО БЫТЬ ...
если (! File_exists ($ target_path)) {}