Results 1 to 3 of 3

Thread: How can I download a file stored on the server

  1. #1
    Join Date
    Nov 2008
    Posts
    996

    How can I download a file stored on the server

    I have a form in PHP that allows a user to send emails with attachments in it. They are stored in a file which is uploaded on the server.

    I can see the list of all the files that are sent by a user X, but I want to download the file and display it in a window to save when he clicks on the file if he wants.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: How can I download a file stored on the server

    Use output() method of class FPDF. It allows either to send the file directly in the browser or save it locally on the disk in PDF format. You can then save it to disk and create a download link on your page instead of displaying the file.

  3. #3
    Join Date
    May 2008
    Posts
    271

    Re: How can I download a file stored on the server

    This code should work for you. It basically forces the file download.

    Code:
      $file = $data ['name']; 
          $path = './'. $file; 
          if (file_exists ($path)) 
          {
              header ('Content-disposition: attachment; filename="'. $file.'"'); 
              header ('Content-Type: application/force-download'); 
              header ('Content-Transfer-Encoding:binary'); 
              header ('Content-Length:'.filesize ($path)); 
              header ('Pragma: no-cache'); 
              header ('Cache-Control: must-revalidate, post-check = 0, pre-check = 0'); 
              header ('Expires:0'); 
              readfile ($path); 
         }
         else 
         {
             $errorFile = 'The file'. $file. "n\ 'exist.  Please excuse us for the inconvenience. '; 
         }

Similar Threads

  1. Where’s file downloaded by IE stored?
    By Beatrix in forum Technology & Internet
    Replies: 5
    Last Post: 25-06-2011, 07:04 AM
  2. How to call SQL server with ASP views and stored procedure?
    By Acalapati in forum Software Development
    Replies: 4
    Last Post: 13-02-2010, 01:51 AM
  3. Use Of Stored Procedure in SQL Server
    By technika in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 11:24 AM
  4. How to Write stored procedure in SQL Server
    By Benito in forum Software Development
    Replies: 3
    Last Post: 03-08-2009, 12:29 PM
  5. Where is the CHKDSK log file stored ?
    By Clarity in forum Windows XP Support
    Replies: 2
    Last Post: 07-12-2007, 02:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,637,371.00812 seconds with 17 queries