Untitled
unknown
plain_text
a year ago
1.4 kB
10
Indexable
$nama_file = "";
if (!empty($_FILES["input_file"]["name"])) {
if ($_FILES["input_file"]["error"] !== UPLOAD_ERR_OK) {
die("Upload error: " . $_FILES["input_file"]["error"]);
}
$upload_path = realpath(__DIR__ . "/../../uploads/");
echo "Resolved upload path: " . $upload_path . "<br>";
// Periksa apakah folder upload benar-benar ada dan dapat ditulis
if (!is_dir($upload_path) || !is_writable($upload_path)) {
die("Upload directory does not exist or is not writable.");
}
// Cek apakah file sementara ada
if (!file_exists($_FILES["input_file"]["tmp_name"])) {
die("Temporary file does not exist.");
}
$nama_file = uniqid() . "-" . basename($_FILES["input_file"]["name"]);
$final_path = $upload_path . "/" . $nama_file;
// Pindahkan file
if (!move_uploaded_file($_FILES["input_file"]["tmp_name"], $final_path)) {
echo "Failed to move the uploaded file.<br>";
print_r(error_get_last());
exit();
} else {
echo "File successfully uploaded and moved to final location.";
}
}Editor is loading...
Leave a Comment