PHP foreach glob to load PDFs from NAS Storage

447 Views Asked by At

I want to create a code using php foreach (glob()) that will load my pdf files from a Network Attach Storage (NAS) is this possible? or there are other option can be used other than using foreach (glob())...

    <div class="container-fluid">
    <div class="row-fluid">
    <div class="span12">
    <table class="table table-striped table-hover data-table">
    <thead>
        <tr>
            <th>Forecast</th>
            <th>Date Issued</th>
            <th>#</th>
            <th>#</th>
            <th>#</th>
            <th>Action</th>                                          
        </tr>
    </thead>   
    <tbody>
        <?php foreach(glob("pdf/*.pdf") as $file)  { ?>
        <tr>
        <td><a href="<?php echo $file; ?>"><?php echo $file; ?></a></td>
        <td>ss</td>
        <td>wdwad</td>
        <td>adwwad</td>
        <td>wdawd</td>            
        <td>dwa</td>
        </tr>
        <?php } ?>                  
    </tbody>
    </table>
    </div>
    </div>
</div>
1

There are 1 best solutions below

2
On

As explained by Guntram, it is totally possible. However it has nothing to do with PHP or coding.

You will have to mount the NAS pdf directory, so it is accessible on the web server running your PHP. You can look at NFS or SSHFS.

Once you have mounted your NAS pdf directory into your local /path/to/pdf, then you can glob("/path/to/pdf/*.pdf"), because your webserver will consider them to be local files.