I have 110 PDF. These are named 001.pdf, 002.pdf [...] 110.pdf. I created all the thumbnail in JPG, called 001.jpg etc.
I created a table in PHP (below).
all the JPG are in ./files/alon/
all the PDF are in ./files/alon/pdf/
So
<img src=".' . $images . $file . '" />
is fine and everything works, but
<td align="center"><a href="' . $images . $big . $file . '">
is not working because $file is looking for 001.jpg in /pdf/ folder.
i need something like
<td align="center"><a href="' . $images . $big . $filename . '.pdf">
i would linke to use the same $filename to create a caption under every image "N° $filename"
here's my code
$images = "./files/alon/";
$big = "pdf/";
$cols = 2;
if ($handle = opendir($images)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != rtrim($big,"/")) {
$files[] = $file;
rsort($files);
}
}
closedir($handle);
}
$colCtr = 0;
echo '<table width="100%" cellspacing="3"><tr>';
foreach($files as $file)
{
if($colCtr %$cols == 0)
echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>';
echo '<td align="center"><a href="' . $images . $big . $file . '"><img src=".' . $images . $file . '" /></a></td>';
$colCtr++;
}
echo '</table>' . "\r\n";
Why don't you replace extension of the file .jpg -->> .pdf in a foreach($files as $file) where you echo stuff on screen ?
foreach($files as $file)
{
$arrPDF = explode(".",$file);
$pdfFile=$arrPDF[0]. ".pdf";
if($colCtr %$cols == 0)
echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>';
echo '<td align="center"><a href="' . $images . $big . $pdfFile . '"><img src=".' . $images . $file . '" /></a></td>';
$colCtr++;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.