Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    sapere se il download del file è stato eseguito completamente

    come riporta il mio titolo del topic il mio problema e ke nn riesco a sapere se il download del file è stato eseguito per intero o solo in parte

    io ho fatto questa funzione

    function output_file($file,$name)
    {
    global $id_utente;
    global $orders_products_id;

    //do something on download abort/finish
    //register_shutdown_function( 'function_name' );
    if(!file_exists($file))die('file not exist!');
    $size = filesize($file);
    $name = rawurldecode($name);
    ignore_user_abort(false);

    if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
    $UserBrowser = "Opera";
    elseif (ereg('MSIE ([0-9].[0-9]{1,2})', $_SERVER['HTTP_USER_AGENT']))
    $UserBrowser = "IE";
    else
    $UserBrowser = '';

    /// important for download im most browser
    $mime_type = ($UserBrowser == 'IE' || $UserBrowser == 'Opera') ? 'application/octetstream' : 'application/octet-stream';
    @ob_end_clean(); /// decrease cpu usage extreme
    header('Content-Type: ' . $mime_type);
    header('Content-Disposition: attachment; filename="'.$name.'"');
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header('Accept-Ranges: bytes');
    header("Cache-control: private");
    header('Pragma: private');

    ///// multipart-download and resume-download
    if(isset($_SERVER['HTTP_RANGE']))
    {
    list($a, $range) = explode("=",$_SERVER['HTTP_RANGE']);
    str_replace($range, "-", $range);
    $size2 = $size-1;
    $new_length = $size-$range;
    header("HTTP/1.1 206 Partial Content");
    header("Content-Length: $new_length");
    header("Content-Range: bytes $range$size2/$size");
    }
    else
    {
    $size2=$size-1;
    header("Content-Length: ".$size);
    }

    $chunksize = 1*(1024*1024);
    $this->bytes_send = 0;
    if ($file = fopen($file, 'r'))
    {
    if(isset($_SERVER['HTTP_RANGE']))
    fseek($file, $range);
    while (!(connection_aborted() || connection_status() == 1)&&!feof($file))
    //while(!feof($file) and (connection_status()==0))
    {
    $buffer = fread($file, $chunksize);
    print($buffer);//echo($buffer); // is also possible
    flush();
    $this->bytes_send += strlen($buffer);
    //sleep(1);//// decrease download speed
    }


    if( headers_sent()&&(connection_status()==0)&&(!connec tion_aborted())&& (feof($file)) ){
    db_connect($_SESSION['dbuser'],$_SESSION['dbpass'],$_SESSION['dbname']);
    mysql_query("update users_products_download set download_count1 where cliente_id=".$id_utente." and orders_products_id=".$orders_products_id)or die("Err SQL: ".mysql_error());
    db_close();
    }
    fclose($file);
    }
    else
    die('error can not open file');
    if(isset($new_length))
    $size = $new_length;
    die();
    }

    nn badate alla lunghezza della funzione...
    anke se uso le funzioni
    headers_sent()
    connection_status()
    connection_aborted()

    nn mi rendo conto se l'utente ha annullato o meno lo caricamento del file...
    spero di essere stato chiaro nell'esporre il problema
    potete aiutarmi?
    vi ringrazio tutti anticipatamente

  2. #2
    raga... nessuno ha un'idea?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.