I'm looking an alternative function to glob. I got this and it work perfectly.
<?php
$tipof = 'FACTURA';
$cliente = '455928';
$files = glob("$cliente-$tipof*.pdf");
foreach ($files as $rows): ?>
<td align="center"> <?php echo end((explode('-', str_replace('.pdf','', $rows)))); ?> </td>
<td align="center"> <?php echo $cliente ?> </td>
<td align="center"> <?php echo "<a target=_blank href=\"".$rows."\">Ver</a>"; ?> </td>
</tr>
The file is in the project folder but how can I do if the file is in a URL? for example something like this: http://192.168.0.196:8080/pdf/
in that url my file is 455928-FACTURA-A106-8694-20171019.pdf
Thanks!
If the files are stored on a different machine not having access to the file system of that machine, I would create some sort of end-point (PHP would be fine) and call end-point via ajax in client or get response with CURL from php server-side, depends on your app needs. end-point would expose results as json to be consumed by your script. I would not go for the ftp or other means to expose file system. Take care of CORS if used in browser.
You cannot
glob
over HTTP.glob
depends on being able to read a list of all files in a directory. HTTP has no concept of "directories" and no standardised way of enumerating parts of a path. It just deals with URLs. URLs don't even have to correspond to files in any way. The URLhttp://example.com/foo/bar
could be backed by a file, or the web server serving this URL could just create the response on the fly based on whatever it feels like. There is no way to enumerate all possible URLs when such URLs could just be made up on the fly, hence there's no way toglob
over HTTP.Iff your web server happened to return a directory listing on the URL
http://192.168.0.196:8080/pdf/
, you could try parsing that.