* @Date Created: 2020/11/15 19:31:15 * @Last modified by: amirhp-com * @Last modified time: 2025/01/08 14:08:56 */ @ini_set("display_errors", 1); error_reporting(E_ERROR); ?> Upload File from URL to WebServer v14

BlackSwan Upload File from URL to Web Server v.14
URL-Address to WebServer

SELF-DESTRUCTION WAS SUCCESSFUL, BYE 👋!'); } ?> Developed by amirhp-com | Give star on Github | your_ip: [ root / new? ]

document.title = 'Uploading ...'; document.querySelector('h1').innerHTML += `
Transferring Origin URL-Address as ".(!empty($folder)?"{$folder}/":"")."{$name}
Please wait until process complete or Press ESC key to cancel
`;"; $time = microtime(true); $remote = fopen($url, 'r'); if (empty($folder)) { $folder = __DIR__; } if (!is_dir($folder)) mkdir($folder, 0777, true); $path_full = $folder . "/" . $name; if (file_exists($path_full)) @unlink($path_full); $local = fopen($path_full, 'w'); stream_context_set_default(array('http' => array('method' => 'HEAD'))); $headers = get_headers($url, true); if (!$headers) { echo "Force uploading fot NON-SSL Servers/Direct Admin hosts ..."; ob_end_flush(); ob_flush(); flush(); $ch = curl_init($url); $fp = fopen($path_full, 'wb'); curl_setopt($ch, CURLOPT_FILE, $fp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_exec($ch); curl_close($ch); fclose($fp); echo "
" . print_r($fp, 1) . "
"; die("
Upload complete!"); } $headers = array_change_key_case(get_headers($url, 1)); $filesize = $headers['content-length']; ob_end_flush(); ob_flush(); flush(); ob_start(); if ($filesize < 1) { echo "
" . print_r($headers, 1) . "
"; echo "
" . print_r($_SERVER, 1) . "
"; exit; } $read_bytes = 0; $num = 0; $progress = 1; $steps = floor($filesize / 2048) / 300 < 0 ? 3 : floor($filesize / 2048) / 300; echo ""; while (!feof($remote)) { $buffer = fread($remote, 2048); fwrite($local, $buffer); $read_bytes += 2048; $num++; if ($num > 4 && $steps > 1) { if ($num % $steps == 0) { $progress = min(100, 100 * $read_bytes / $filesize); echo ""; } } ob_end_flush(); ob_flush(); flush(); ob_start(); } fclose($remote); fclose($local); $should_extract = "https://wordpress.org/latest.zip" == $url; echo ""; ob_end_flush(); ob_flush(); flush(); if ($should_extract) { echo ""; ob_end_flush(); ob_flush(); flush(); ob_start(); $rootDir = __DIR__; $zipFile = $path_full; $tempDir = $rootDir . '/temp/wordpress'; $continue = false; $zip = new ZipArchive; if ($zip->open($zipFile) === TRUE) { $zip->extractTo($rootDir . '/temp'); $zip->close(); $continue = true; echo ""; echo ""; ob_end_flush(); ob_flush(); flush(); ob_start(); } else { echo ""; ob_end_flush(); ob_flush(); flush(); ob_start(); } if ($continue) { if (!is_dir($tempDir)) { echo ""; ob_end_flush(); ob_flush(); flush(); ob_start(); } // Step 3: Move files from the 'wordpress' folder to the root directory $files = scandir($tempDir); $jf = 0; $jfl = 0; foreach ($files as $file) { if ($file !== '.' && $file !== '..') { $source = $tempDir . '/' . $file; $destination = $rootDir . '/' . $file; // Move the file or directory if (is_dir($source)) { $jfl++; rename($source, $destination); } else { $jf++; rename($source, $destination); } } } echo ""; ob_end_flush(); ob_flush(); flush(); ob_start(); // Step 4: Remove the temporary folder $tempPath = $rootDir . '/temp'; if (is_dir($tempPath)) { if (rmdir($tempPath)) { echo ""; ob_end_flush(); ob_flush(); flush(); ob_start(); } else { // Fallback to recursive deletion if the folder isn't empty rmdir_recursive($tempPath); echo ""; ob_end_flush(); ob_flush(); flush(); ob_start(); } }else{ echo ""; ob_end_flush(); ob_flush(); flush(); ob_start(); } // Step 5: Optionally, delete the ZIP file if (file_exists($zipFile)) { @unlink($zipFile); @unlink($folder . "/license.txt"); @unlink($folder . "/readme.html"); @unlink($folder . "/xmlrpc.php"); echo ""; ob_end_flush(); ob_flush(); flush(); ob_start(); } } } ob_end_flush();ob_flush(); flush(); echo ""; echo "all done ./"; exit; } ?>
Origin URL-Address

Destination Folder

Destination Filename
DO NOT KEEP THIS FILE ON YOUR SERVER, DELETE IT AS SOON AS YOU'RE DONE. [🗑️] 0 ? "$h:" : "") . sprintf('%02d', $m) . ':' . sprintf('%02d', $s); } function rmdir_recursive($dir) { $files = array_diff(scandir($dir), ['.', '..']); foreach ($files as $file) { $path = $dir . '/' . $file; is_dir($path) ? rmdir_recursive($path) : unlink($path); } return rmdir($dir); } /*################################################## Lead Developer: [amirhp-com](https://amirhp.com/) ##################################################*/