日期:2014-05-17  浏览次数:20563 次

关于这个php远程下载的代码!!!!!!!!!!!!!
PHP code
 <form method="post">
<input name="url" size="50" />
<input name="submit" type="submit" />
</form>
< ?php
// maximum execution time in seconds
set_time_limit (24 * 60 * 60);
if (!isset($_POST['submit'])) die();
// folder to save downloaded files to. must end with slash
$destination_folder = 'temp/';
 
$url = $_POST['url'];
$newfname = $destination_folder . basename($url);
$file = fopen ($url, "rb");
if ($file) {
$newf = fopen ($newfname, "wb");
if ($newf)
while(!feof($file)) {
fwrite($newf, fread($file, 1024 * 8 ), 1024 * 8 );
}
}
if ($file) {
fclose($file);
}
if ($newf) {
fclose($newf);
}
?>



这个 代码,他的保存地址为 temp/ 有没有方法 让 这个文件保存地址 为 接受来自GET的数据 比如 a.php?file=index 
则 目录为 index 有没有方法搞成这样  




------解决方案--------------------
$destination_folder = 'temp/';

改为

$destination_folder = $_GET['file'] . '/';