Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7368131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:37:34+00:00 2026-05-29T03:37:34+00:00

Possible Duplicate: PHP list all files in directory ive got a cron job running

  • 0

Possible Duplicate:
PHP list all files in directory

ive got a cron job running creating .xls files every 24hrs, they are creating them in a directory on my site called http://www.mysite.com/sheets

what i want to do is make a webpage where i can go to and see all the .xls files in that directory and download the ones i was instead of having to download them using an ftp client.

Is there a name for this sort of thing ? what would i write it in ? i was thinking i could do it in php by echoing the folders contents, would that work ?

cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:37:35+00:00Added an answer on May 29, 2026 at 3:37 am

    You could activate directory listing within your webserver, or you can use a function like glob(“*.xls”) to list the files and echo their path on the webserver or you can send a file to the browser like this:

    <?php
    $filename = "path/to/your/file.xls";
    $real_filename = "file.xls";
    header('Content-Transfer-Encoding: none');
    header('Content-Type: application/octet-stream; name="' . $real_filename . '"');    
    header('Content-Disposition: attachment; filename=' . $real_filename);                
    $size = @filesize($filename);
    if ($size > 0) {
        header('Content-length: '.$size);
    } else {
        header('Content-length: '.@strlen(@file_get_contents($filename)));
    }
    readfile($filename);
    exit;
    ?>
    

    If you want to list a directory use this:

    $handle = opendir("./");
    while (false !== ($file = readdir($handle))) {
        $fileinfo = pathinfo($file);
        if (strtolower($fileinfo[extension]) == "xls") {
            echo $file;    
        }
    }
    closedir($handle);
    

    Or this:

    foreach (glob("*.[xX][lL][sS]") as $filename) {
        echo $filename;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP: running scheduled jobs (cron jobs) How to run a PHP file
Possible Duplicate: List all folders on my computer (php) I have tried: $handle =
Possible Duplicate: Best way to stop SQL Injection in PHP I am creating a
Possible Duplicate: Get the hierarchy of a directory with PHP Getting the names of
Possible Duplicate: How to find all substrings of a string in PHP Find all
Possible Duplicate: PHP get all arguments as array? Within a javascript function arguments always
Possible Duplicate: Threads in PHP. I m getting a list of 20 urls. I
Possible Duplicate: How to create comma separated list from array in PHP? I have
Possible Duplicate: Javascript equivalent of PHP's list() In PHP you can do assignment like
Possible Duplicate: PHP Linkify Links In Content I've got a little stuck with finding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.