I need help to download the webpages from internet using php script
.but right now i have script which is downloading webpage from internet. But it is downloading the webpages with always same name like index.html name.
i want to download the webpage with its own name in url .like aboutus page download with aboutus.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<form method="post">
<input name="url" size="50" placeholder="URL" />
<input name="submit" type="submit" />
</form>
</body>
</html>
<?php
// maximum execution time in seconds
set_time_limit (24 * 60 * 60);
if (isset($_POST['submit'])) {
$url = parse_url($_POST['url']);
$folder = $url['host'];
if (array_key_exists('path', $url)) {
$file = explode('.', str_replace('/', '', $url['path']));
$file .= '.html';
} else {
$file = 'index.html';
}
if (!sizeOf(glob($folder))) {
mkdir($folder);
}
file_put_contents($folder . '/' . $file, fopen($_POST['url'], 'r'));
}
?>