Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Download

  1. #1

    Download

    io sto facendo uno script per downloads e vorrei che se il file da scaricare fosse un txt nn lo aprisse con il browser ma lo scaricasse come un normale file come faccio?

  2. #2
    puoi utilizzare la funzione php header
    http://it.php.net/manual/en/function.header.php
    copio e incollo dalla documentazione
    If you want the user to be prompted to save the data you are sending, such as a generated PDF file, you can use the Content-Disposition header to supply a recommended filename and force the browser to display the save dialog.

    <?php
    // We'll be outputting a PDF
    header('Content-type: application/pdf');

    // It will be called downloaded.pdf
    header('Content-Disposition: attachment; filename="downloaded.pdf"');

    // The PDF source is in original.pdf
    readfile('original.pdf');
    ?>
    Saluti a tutti
    Riccardo

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 © 2024 vBulletin Solutions, Inc. All rights reserved.