通过我的服务器下载远程文件,并在下载后删除该文件

时间:2016-10-19 08:57:50

标签: php curl download fopen readfile

我想从我的网站下载vodlocker视频 http://93.186.255.20/vodlocker.view.php?id=nxema6gm8d8n&title=Watch-The-Amazing-Spider-Man-(2014)-Low-Quality-Full-Movie

请帮助解决方案:)

vodlocker.dl.php

<?php
ini_set('display_errors', 1);
set_time_limit(30);
$url = base64_decode($_GET['url']);
$title = $_GET['title'];
$filename = dirname(__file__).'/tmp/' . $title . '.mp4';
file_put_contents($filename, file_get_contents($url));


if(file_exists($filename)){

    //Get file type and set it as Content Type
    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    header('Content-Type: ' . finfo_file($finfo, $filename));
    finfo_close($finfo);

    //Use Content-Disposition: attachment to specify the filename
    //header('Content-type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.basename($filename).'"');

    //No cache
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');

    //Define file size
    header('Content-Length: ' . filesize($filename));

    ob_clean();
    flush();
    readfile($filename);
    exit;
}

0 个答案:

没有答案