Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 13-05-2009
Member
 
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.
Reply With Quote
  #2  
Old 13-05-2009
Member
 
Join Date: May 2008
Posts: 2,383
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.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #3  
Old 13-05-2009
XSI XSI is offline
Member
 
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. '; 
     }
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 10:40 AM.