Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    May 2012
    Posts
    61
    Thanks
    1
    Thanked 0 Times in 0 Posts

    download link resume capabilites problem

    i have problem download link resume capabilities problem
    i use php melody video script with YouTube hd proxy php script

    first link this is hosted on my server
    and this give me fast speed with idm resume capabilities yes
    check this

    http://www.7videotube.com/uploads/videos/a364fb41b9.flv

    second this video not host on my site its work remotely YouTube through YouTube hd proxy script
    but this download video not give me resume capabilities No on idm
    check this

    http://www.7videotube.com/filesrep/vid/019653b2e.flv

    i want its give me always idm resume capabilites yes please tell me what i
    do i found download script on my code but not found please tell me what i change
    help me please

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,329
    Thanks
    60
    Thanked 526 Times in 513 Posts
    Blog Entries
    4
    You need to look into the use of content range headers.

    This was on php.net in the USER COMMENTS (one of the best places to look).

    PHP Code:
    <?php

    function dl_file_resumable($file$is_resume=TRUE)
    {
        
    //First, see if the file exists
        
    if (!is_file($file))
        {
            die(
    "<b>404 File not found!</b>");
        }

        
    //Gather relevent info about file
        
    $size filesize($file);
        
    $fileinfo pathinfo($file);
       
        
    //workaround for IE filename bug with multiple periods / multiple dots in filename
        //that adds square brackets to filename - eg. setup.abc.exe becomes setup[1].abc.exe
        
    $filename = (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE')) ?
                      
    preg_replace('/\./''%2e'$fileinfo['basename'], substr_count($fileinfo['basename'], '.') - 1) :
                      
    $fileinfo['basename'];
       
        
    $file_extension strtolower($path_info['extension']);

        
    //This will set the Content-Type to the appropriate setting for the file
        
    switch($file_extension)
        {
            case 
    'exe'$ctype='application/octet-stream'; break;
            case 
    'zip'$ctype='application/zip'; break;
            case 
    'mp3'$ctype='audio/mpeg'; break;
            case 
    'mpg'$ctype='video/mpeg'; break;
            case 
    'avi'$ctype='video/x-msvideo'; break;
            default:    
    $ctype='application/force-download';
        }

        
    //check if http_range is sent by browser (or download manager)
        
    if($is_resume && isset($_SERVER['HTTP_RANGE']))
        {
            list(
    $size_unit$range_orig) = explode('='$_SERVER['HTTP_RANGE'], 2);

            if (
    $size_unit == 'bytes')
            {
                
    //multiple ranges could be specified at the same time, but for simplicity only serve the first range
                //http://tools.ietf.org/id/draft-ietf-http-range-retrieval-00.txt
                
    list($range$extra_ranges) = explode(','$range_orig2);
            }
            else
            {
                
    $range '';
            }
        }
        else
        {
            
    $range '';
        }

        
    //figure out download piece from range (if set)
        
    list($seek_start$seek_end) = explode('-'$range2);

        
    //set start and end based on range (if set), else set defaults
        //also check for invalid ranges.
        
    $seek_end = (empty($seek_end)) ? ($size 1) : min(abs(intval($seek_end)),($size 1));
        
    $seek_start = (empty($seek_start) || $seek_end abs(intval($seek_start))) ? max(abs(intval($seek_start)),0);

        
    //add headers if resumable
        
    if ($is_resume)
        {
            
    //Only send partial content header if downloading a piece of the file (IE workaround)
            
    if ($seek_start || $seek_end < ($size 1))
            {
                
    header('HTTP/1.1 206 Partial Content');
            }

            
    header('Accept-Ranges: bytes');
            
    header('Content-Range: bytes '.$seek_start.'-'.$seek_end.'/'.$size);
        }

        
    //headers for IE Bugs (is this necessary?)
        //header("Cache-Control: cache, must-revalidate");  
        //header("Pragma: public");

        
    header('Content-Type: ' $ctype);
        
    header('Content-Disposition: attachment; filename="' $filename '"');
        
    header('Content-Length: '.($seek_end $seek_start 1));

        
    //open the file
        
    $fp fopen($file'rb');
        
    //seek to start of missing part
        
    fseek($fp$seek_start);

        
    //start buffered download
        
    while(!feof($fp))
        {
            
    //reset time limit for big files
            
    set_time_limit(0);
            print(
    fread($fp1024*8));
            
    flush();
            
    ob_flush();
        }

        
    fclose($fp);
        exit;
    }

    ?>
    Be warned, you need to be very good at debugging to use this.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    New Coder
    Join Date
    May 2012
    Posts
    61
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i use this code in my function but not work please tell me
    how to mention filesrep/vid/ dir in this code then download now about this dir

    only tell me filesrep/vid/ this dir where add in this code

  • #4
    New Coder
    Join Date
    May 2012
    Posts
    61
    Thanks
    1
    Thanked 0 Times in 0 Posts
    help me please

  • #5
    New Coder
    Join Date
    May 2012
    Posts
    61
    Thanks
    1
    Thanked 0 Times in 0 Posts
    @tangoforce please help me


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •