Ketika mengupload file (misalnya script) ke hosting lewat fitur uploadnya cPanel, tidak jarang “proteksi” nya terlalu berlebihan.
Contohnya seperti ini, mau upload script CKEditor, malah terdeteksi virus:
Bagaimana Solusinya?
Paling simpel ya, upload lewat kode php import saja.
Pertama buatlah kode import.php di direktori yang mau disimpan, kodenya:
<?php
// Periksa apakah form telah dikirim
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Dapatkan URL file yang akan diimpor
$file_url = $_POST['file_url'];
// Tentukan direktori tujuan untuk menyimpan file
$target_dir = __DIR__ . '/';
$target_file = $target_dir . basename($file_url);
// Unduh file dari URL
if (copy($file_url, $target_file)) {
echo "File berhasil diimpor: " . basename($target_file);
} else {
echo "Terjadi kesalahan saat mengimpor file.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Import File</title>
</head>
<body>
<h1>Import File</h1>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
URL File: <input type="text" name="file_url"><br>
<input type="submit" name="submit" value="Import">
</form>
</body>
</html>
Kedua : Upload file nya di tempat upload file temporary yang memberikan link url file langsung, misalnya :
- https://tmpfiles.org/
- https://uguu.se/
Ketika : Tinggal import langsung dari url nya.
Selesai.