Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
748 views
in Technique[技术] by (71.8m points)

Alternative to glob php

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">&nbsp;<?php echo end((explode('-', str_replace('.pdf','', $rows)))); ?> &nbsp;</td>
    <td align="center">&nbsp;<?php echo $cliente ?> &nbsp;</td>
    <td align="center">&nbsp;<?php echo "<a target=_blank href="".$rows."">Ver</a>"; ?> &nbsp;</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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 URL http://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 to glob over HTTP.

I? your web server happened to return a directory listing on the URL http://192.168.0.196:8080/pdf/, you could try parsing that.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...