Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2001
    Messaggi
    321

    download file - apri o salva

    Ciao a tutti

    ho uno script che ho trovato in rete che dovrebbe far comparire la maschera del browser per salvare o aprire il file che si sta scaricando senza aprirlo in automatico.


    se salvo il file e lo apro dopo tutto ok ma se lo apro direttamente mi da errore per esempio l'acrobat reader che dovrebbe leggere il file

    ecco lo script che sto provando



    Codice PHP:

    //header("Content-Type: $file_mime");
    header('Content-type: application/pdf');
    header("Content-Length: " filesize($file_path));
    $agent $_SERVER["HTTP_USER_AGENT"];
    if( 
    is_int(strpos($agent"MSIE")) ){
        
    # Remove reserved chars: :\/*?"<>|
        
    $fn preg_replace('/[:\\x5c\\/*?"<>|]/''_'$file_name);
        
    # Non-standard URL encoding:
        
    header("Content-Disposition: attachment; filename="
        
    rawurlencode($fn));
    } else if( 
    is_int(strpos($agent"Gecko")) ){
        
    # RFC 2231:
        
    header("Content-Disposition: attachment; filename*=UTF-8''"
        
    rawurlencode($file_name));
    } else if( 
    is_int(strpos($agent"Opera")) ) {
        
    # Remove reserved chars: :\/*{?
        
    $fn preg_replace('/[:\\x5c\\/{?]/''_'$file_name);
        
    # RFC 2231:
        
    header("Content-Disposition: attachment; filename*=UTF-8''"
        
    rawurlencode($fn));
    } else {
        
    # RFC 2616 ASCII-only encoding:
        
    $fn mb_convert_encoding($file_name"US-ASCII""UTF-8");
        
    $fn = (string) str_replace("\\""\\\\"$fn);
        
    $fn = (string) str_replace("\"""\\\""$fn);
        
    header("Content-Disposition: attachment; filename=\"$fn\"");
    }
    readfile($file_path); 
    ::Steve::

  2. #2
    Utente di HTML.it
    Registrato dal
    Aug 2001
    Messaggi
    321
    ovviamente mancano

    $file_name = "/dirprova/"
    $file_path = "file.php";
    ::Steve::

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2001
    Messaggi
    321
    up
    ::Steve::

  4. #4

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.