Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11

Discussione: inclusione file .zip

  1. #1

    inclusione file .zip

    Ciao a tutti,
    vorrei far scaricare dei file .zip che non si trovano nella root principale del sito. L'unico modo che conosco per raggiungere i file è tramite "include" ma invece di darmi la possibilità di scaricare, interpreta il file stampando a video scritte indecifrabili.
    C'è un modo per risolvere?

    Grazie
    Domenico
    La mia rivista: SET immagini segni e storie
    "Ogni uomo confonde i limiti del suo campo visivo con i confini del mondo" (A. Schopenhauer)

  2. #2
    che percorso hai usato?
    <?php include ('cartella1/cartella2/file.zip'); ?>

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    questo link è stato postato una mezza milionata di volte...

    http://www.devpro.it/php4_id_72.html

    ciao
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  4. #4
    <?php include("/home/usr/file/A006.zip"); ?>
    La mia rivista: SET immagini segni e storie
    "Ogni uomo confonde i limiti del suo campo visivo con i confini del mondo" (A. Schopenhauer)

  5. #5
    [supersaibal]Originariamente inviato da Andrea1979
    questo link è stato postato una mezza milionata di volte...

    http://www.devpro.it/php4_id_72.html

    ciao [/supersaibal]
    Grazie Andrea,
    ma non riesco a linkare ad un file fuori dalla root principale...
    puoi suggerirmi?
    La mia rivista: SET immagini segni e storie
    "Ogni uomo confonde i limiti del suo campo visivo con i confini del mondo" (A. Schopenhauer)

  6. #6
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    in che senso? Sei sicuro che il path sia corretto?
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  7. #7
    ecco il risultato

    www.pieffe.net/prova.php


    questo è lo script:
    <html>
    <head>
    <?php
    function forceDownload( &$file ) {
    /**
    * Function forceDownload:
    * download any type of file if it exists and is readable
    * -------------------------------------
    * @author Andrea Giammarchi
    * @date 18/01/2005
    * @compatibility PHP >= 4.3.0
    */
    if( file_exists( $file ) == true && is_readable( $file ) == true ) {
    $filename = &basename( $file );
    if( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) {
    $parsename = &explode( '.', $filename );
    $last = count( $parsename ) - 1;
    $filename = &implode( '%2E', array_slice( $parsename, 0, $last ) );
    $filename .= '.'.$parsename[$last];
    }
    $content = &file_get_contents( $file );
    header( 'Content-Type: application/octet-stream' );
    header( 'Content-Disposition: attachment; filename='.$filename );
    header( 'Content-Length:'.strlen( $content ) );
    header( 'Content-Transfer-Encoding: binary' );
    echo $content;
    exit(0);
    }
    }
    ?>

    </head>

    <body>


    <?php
    $file = "/home/pieffe/fustelle/A006.zip";
    forceDownload($file); ?>
    </body>
    </html>
    La mia rivista: SET immagini segni e storie
    "Ogni uomo confonde i limiti del suo campo visivo con i confini del mondo" (A. Schopenhauer)

  8. #8
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    ti becchi l'headers already sent... perché stai provando a mandare headers diversi dopo che hai già mandato codice html.

    Prova così, e segnalaci gli eventuali altri errori.

    Codice PHP:
    <?php 
    function forceDownload( &$file ) { 
    /** 
    * Function forceDownload: 
    * download any type of file if it exists and is readable 
    * ------------------------------------- 
    * @author Andrea Giammarchi 
    * @date 18/01/2005 
    * @compatibility PHP >= 4.3.0 
    */ 
    if( file_exists$file ) == true && is_readable$file ) == true ) { 
    $filename = &basename$file ); 
    if( 
    strpos$_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) { 
    $parsename = &explode'.'$filename ); 
    $last count$parsename ) - 1
    $filename = &implode'%2E'array_slice$parsename0$last ) ); 
    $filename .= '.'.$parsename[$last]; 

    $content = &file_get_contents$file ); 
    header'Content-Type: application/octet-stream' ); 
    header'Content-Disposition: attachment; filename='.$filename ); 
    header'Content-Length:'.strlen$content ) ); 
    header'Content-Transfer-Encoding: binary' ); 
    echo 
    $content
    exit(
    0); 

    }

    $file "/home/pieffe/fustelle/A006.zip"
    forceDownload($file);
    ?>
    Ossia, salta in tronco tutta la parte html.
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  9. #9
    Va meglio, viene eliminato il problema warning.. ma non riesco ancora a far scaricare il file

    www.pieffe.net/prova2.php
    La mia rivista: SET immagini segni e storie
    "Ogni uomo confonde i limiti del suo campo visivo con i confini del mondo" (A. Schopenhauer)

  10. #10
    scusami.... funziona benissimo
    grazie mille
    La mia rivista: SET immagini segni e storie
    "Ogni uomo confonde i limiti del suo campo visivo con i confini del mondo" (A. Schopenhauer)

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.