Jump to content

Download via HTTP HEADER - How To Make It Resumable?


Bigball

Recommended Posts

I have this code:

 

<?php
error_reporting(0);
include('config.php');
if(!isset($_GET['id']))
{
header("Location: index.php");
}
else{
$file = mysql_query("Select * from files where id='".$_GET['id']."'");
$query = "SELECT COUNT(name) FROM files where id='".$_GET['id']."'"; 

$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
if($row['COUNT(name)'] == 0)
{
die("The requested file doesn't exist.");
}
}

while($row = mysql_fetch_array($file))
{
if($row['ip'] != $_SERVER['REMOTE_ADDR'])
{
	die("This file is being leeching by another person. Please try again later.");
}


$local_file = "files/" . $row['hash'] . "_" . $row['name'];
$download_file = $row['name'];
if(file_exists($local_file) && is_file($local_file)) {
header("Cache-Control: public");
    header("Content-type: application/force-download");
    header("Content-Transfer-Encoding: Binary");
    header('Content-Length: '.filesize($local_file));
    header('Content-Disposition: filename='.$download_file);
readfile($local_file);
}
else {
    die('Error: The file '.$row['name'].' has been deleted!');
}
}
}
?>

Of couse, that works probally. But I have a problem with it, that is it doesnt support resume when download. I 've tried alot of ways on the internet but i coudnt make it resumable.

Please, everybody please help me to make it resumable. :(. It's very kind of you.

Thanks alot for visiting my topic.

Best Regards,

Bigball

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.