1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Rep Power

    Opening and reading the files from a folder

    I am new to PHP..
    I have a folder which consists of .doc and .xls format files.
    I want to display all the files from the folder and when i double click on a particular file,i want to read that particular file..How to do it in php??plz help..
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Rep Power
    You can't, at least not directly. You are double clicking in a browser and PHP no longer knows anything about that page. Once the page is output PHP is gone. However, you can detect the double click with javascript and from there open a new window or tab that loads the double clicked file. Alternatively you could use Ajax to load the file but that may be overkill for what you want. Thirdly, you could also let the user select the file, click a button to submit it and then PHP can output the appropriate file.

    As for loading all the file names from a directory, that is the easy part. Simply use 'readdir'.
    Last edited by gw1500se; November 1st, 2012 at 07:53 AM.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.

IMN logo majestic logo threadwatch logo seochat tools logo