Jump to content

Recommended Posts

Ok this is what I would like the script to do.

 

1: scan a target directory and save file information into a mysql db.

  a. filename

  b. filesize

  c. last modified timestamp

  d. file location

 

2. Display directory and allow the list to be modified via Last modified, filesize or name. ascending or descending.

 

3: Allow the directory list to be searched and have displayed results also be affected by point 2.

 

4. Allow the filename displayed to be a clickable download.

 

 

Any help to point me into the direction of an existing script that can do this would be extremely helpful.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/73504-looking-for-a-script-to-do-the-following/
Share on other sites

  • 2 months later...

function scanDir($dirname) {

  if (is_dir($dirname)) {    //Operate on dirs only

      $result=array();

      if (substr($dirname,-1)!='/') {$dirname.='/';}    //Append slash if necessary

      $handle = opendir($dirname);

      while (false !== ($file = readdir($handle))) {

  if ($file!='.' && $file!= '..') {    //Ignore . and ..

      $path = $dirname.$file;

      // You can write ur sql query here to insert

                      // You have the file name and path but need to

                    //use some file fuctions to get the other things.

                    // Or you can return the array and get the file and path

                  // one by one and can do the operation

  }

      }

      closedir($handle);

      $result[].=$dirname;

      return $result;    //Return array of  items

      }else{

      return false;    //Return false if attempting to operate on a file

  }

}

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.