Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

php and filesize

Posted on 2013-01-02
8
Medium Priority
?
244 Views
Last Modified: 2013-01-02
On the attached page, the following scripts wotk fine with a static image:
--------------------------
<?php
echo filesize("downloads/picture3hr.jpg");
echo "&nbsp;&nbsp;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
0
Comment
Question by:doctorbill
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 38737063
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)); ?>

Open in new window

0
 

Author Comment

by:doctorbill
ID: 38737094
Doesn't work - all I get is the echo of the script on the page
0
 
LVL 35

Expert Comment

by:gr8gonzo
ID: 38737134
Can you show us a full screenshot?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:doctorbill
ID: 38737170
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.";
0
 
LVL 35

Accepted Solution

by:
gr8gonzo earned 2000 total points
ID: 38737207
Oh, sorry - you should enclose lines 6, 7, and 8 with <?php (lines 6-8) ?>
0
 

Author Comment

by:doctorbill
ID: 38737246
I get the following next to the relevant image:

FW_001.jpg is 0 Mega
FW_002.jpg is 0 Mega
FW_003.jpg is 0 Mega

So it is working in terms of the script on the page but no size is being returned
0
 

Author Comment

by:doctorbill
ID: 38737256
Correction - it is working. I didn't have the correct (full) image  path in the database
0
 

Author Closing Comment

by:doctorbill
ID: 38737302
solved
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question