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

    header(), download di documenti e path

    Salve,

    ho una pagina dove si possono scaricare dei pdf. Il link porta a
    < download.php?file=filepdf.PDF>

    All' interno di download ho il seguente codice:
    $fname = $path.$file;

    if (file_exists($fname)){
    header("Content-Disposition: attachment; filename=$f");
    header("Content-Length: ".filesize($fname));

    readfile("$fname");

    Ok, tutto funziona se l'utente, quando appare la finestra di "salva" "apri" "cancella", sceglie SALVA, se invece sceglie APRI
    si apre AcrobatReader e compare la triste scritta "There was an error opening this document, this file cannot be found"!

    PERCHE'? Cosa sbaglio?

    Aiuto

  2. #2
    < download.php?file=filepdf.PDF>
    download.php?file=../../../etc/password
    <?php echo ' Emiliano Gabrielli (aka AlberT) ',"\n",
    ' socio fondatore e membro del direttivo del GrUSP ',"\n",
    ' AlberT_at_SuperAlberT_it - www.SuperAlberT.it ',"\n",
    ' IRC: #php,#AES azzurra.com ',"\n",'ICQ: 158591185'; ?>

  3. #3
    per quanto riguarda la domanda invece devi inviare un header che dia il corretto Content-Type (application/pdf mi pare)
    <?php echo ' Emiliano Gabrielli (aka AlberT) ',"\n",
    ' socio fondatore e membro del direttivo del GrUSP ',"\n",
    ' AlberT_at_SuperAlberT_it - www.SuperAlberT.it ',"\n",
    ' IRC: #php,#AES azzurra.com ',"\n",'ICQ: 158591185'; ?>

  4. #4
    Scusa ma questo non l'ho capito...

  5. #5
    Il content Type (application/pdf) non cambia nulla.

  6. #6
    Codice PHP:
    $fname $path.$_GET['file']; 
    if (!
    is_readable($fname)) {
       
    header('Location: [url]http://tuosito.com/error.php?errno=12345[/url]');
       exit;
    }
     
    header('Content-Type: application/pdf'); 
    header("Content-Disposition: attachment; filename = $file"); 
    header('Expires: 0'); 
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); 
    header ("Pragma: pubblic"); 
    readfile($fname); 
    <?php echo ' Emiliano Gabrielli (aka AlberT) ',"\n",
    ' socio fondatore e membro del direttivo del GrUSP ',"\n",
    ' AlberT_at_SuperAlberT_it - www.SuperAlberT.it ',"\n",
    ' IRC: #php,#AES azzurra.com ',"\n",'ICQ: 158591185'; ?>

  7. #7
    ovviamente l'href nel Location l'ha inserita il forum :-)
    <?php echo ' Emiliano Gabrielli (aka AlberT) ',"\n",
    ' socio fondatore e membro del direttivo del GrUSP ',"\n",
    ' AlberT_at_SuperAlberT_it - www.SuperAlberT.it ',"\n",
    ' IRC: #php,#AES azzurra.com ',"\n",'ICQ: 158591185'; ?>

  8. #8
    Funziona,

    tu mi hai salvato e io te ne sono grato, hai la mia benedizione ))

  9. #9
    non benedire me, ma S. Google
    <?php echo ' Emiliano Gabrielli (aka AlberT) ',"\n",
    ' socio fondatore e membro del direttivo del GrUSP ',"\n",
    ' AlberT_at_SuperAlberT_it - www.SuperAlberT.it ',"\n",
    ' IRC: #php,#AES azzurra.com ',"\n",'ICQ: 158591185'; ?>

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.