I don't understand what's wrong, everything looks correct, both from permissions, file locations, file names and functions
$folderPath = __DIR__ . "/assets/img/upload/";
$gambar = $_FILES['img'];
if (!file_exists($folderPath)) mkdir($folderPath);
if (file_exists($folderPath . $gambar["name"])) {
return $gambar["name"] . " already in folder! ";
} else {
$sourcePath = $gambar['tmp_name'];
$acak = rand(11111111, 99999999);
$NewImageName = str_replace(' ', '', 'gambar' . $acak . '.' . $file_extension);
$targetPath = $folderPath . $NewImageName;
$move = move_uploaded_file($sourcePath, $targetPath);
if (!$move) {
$respon = [
"status" => false,
"msg" => "Simpan berkas Gambar gagal!",
"name" => $NewImageName,
"source" => $sourcePath,
"location" => $targetPath,
"gambar_info" => $gambar,
];
print_r($respon);
die();
}
}
php.ini
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
response given
The file should be successfully moved to the "upload" folder as in $targetPath