How to use PHP DOM to output filesize for files listed in the table of an HTML page? -
example.html (huge table contains hundreds of files impossible list of them arrays):-
<table> <tbody> <tr> <td class="book"><a class="booklink" href="../file1.pdf" >book1</a></td> <td class="year">2007</td> <td class="pages">32p</td> </tr> <tr> <td class="book"><a class="booklink" href="../file2.pdf" >book2</a></td> <td class="year">2010</td> <td class="pages">12p</td> </tr> <tr> <td class="book"><a class="booklink" href="../file3.pdf" >book3</a></td> <td class="year">2013</td> <td class="pages">42p</td> </tr> <!--------and on... -------->
how use php dom trace filesize file1.pdf, file2.pdf, file3.pdf (and on), outputed new table data classname "filesize" automatically showing __kb(or.__mb if larger)?
<table> <tbody> <tr> <td class="book"><a class="booklink" href="../file1.pdf" >book1</a></td> <td class="year">2007</td> <td class="pages">32p</td> <td class="filesize">___kb(or_.__mb if larger)</td> </tr> <tr> <td class="book"><a class="booklink" href="../file2.pdf" >book2</a></td> <td class="year">2010</td> <td class="pages">12p</td> <td class="filesize">___kb(or_.__mb if larger)</td> </tr> <tr> <td class="book"><a class="booklink" href="../file3.pdf" >book3</a></td> <td class="year">2013</td> <td class="pages">42p</td> <td class="filesize">___kb(or_.__mb if larger)</td> </tr> <!--------and on... -------->
the way can see right request each table line's file (with curl or similar), collect file size in local file system, output new table line, delete temp file , move on... of course isn't in terms of performance, you'll downloading every file target server.
if target server under control , php enabled, implement simple "filesize.php" script returns info you, based on parameter describing file name (beware of security breaches, though).
Comments
Post a Comment