On the attached page, the following scripts wotk fine with a static image:
--------------------------
<?php
echo filesize("downloads/picture3hr.jpg");
echo " File Size in Bytes";
?><br />
<?php
$f = "downloads/picture3hr.jpg";
$size = filesize($f) * .000001;
echo $f . " is " . $size . " Mega bytes.";
?>
----------------------
The above scripts were used just to test the page
I am trying to get the file size from the following code being fed from a mysql recordset:
------------------
<?php do {
?>
<img src="<?php echo $row_imgs[im_thumb]; ?>" border="0" /><a href="download.php?file=<?php echo $row_imgs[im_hres]; ?>">D</a>
<?php } while ($row_imgs = mysql_fetch_assoc($imgs)); ?>
-------------------
Can someone please point me in the direction of how to add the filesize function to this loop so that it returns to file size for all returned records index.php
PHP
Last Comment
doctorbill
8/22/2022 - Mon
gr8gonzo
This might work, depending on where the images actually are, but you didn't say anything about where you want the filesize to show up, so the code below will simply put it to the side:
<?php do { ?> <img src="<?php echo $row_imgs["im_thumb"]; ?>" border="0" /><a href="download.php?file=<?php echo $row_imgs["im_hres"]; ?>">D</a>$f = $row_imgs["im_thumb"];$size = filesize($f) * .000001;echo $f . " is " . $size . " Mega bytes."; <?php } while ($row_imgs = mysql_fetch_assoc($imgs)); ?>
The following is repeated down the page next to each image:
----------------------
$f = $row_imgs["im_thumb"]; $size = filesize($f) * .000001; echo $f . " is " . $size . " Mega bytes.";
Open in new window