close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues


Bytes expression in database

Thread began 9/15/2012 6:28 am by rikaG_510 | Last modified 9/19/2012 5:06 am by rikaG_510 | 620 views | 4 replies |


Bytes expression in database


At the moment, my insert.php page sends image size to a database.
In a database, each size is shown as (for example) ; "177600", which is 178kb.

Is there any way to upload the image size, not as 17760, but as 178?

So far all the images I have are around 200kb, but I might have images in mb in the future for downloading.
So would you also tell me how to show all sizes in mb as well?

Thank you for your help in advance.


Sign in to reply to this post

Jason ByrnesWebAssist

the file size is returned in bytes.

to show it in kb or MB, you would need to do the math to perform the conversion

177600 bytes is not 178 kb.

there are 1024 bytes to a kb.

177600 bytes is 173.4375 KB

177600 / 1024 = 173.4375

1 Megabyte = 1048576 bytes, so to convert to mega bytes, you would use:

177600 / 1048576 = 0.169372558594

Sign in to reply to this post


Thank you Jason for a detailed explanation.
I'm not a math person, so it helps.

The reason why I said 177600 = 178 kb is because that is how my laptop is showing when I check the file info for this particular image, though it shows 177600 in the database after inserted from my insert.php.

Now you showed me the calculation, I need to ask you how to add this calculation to the process of inserting images to database (this is what I really wanted to know to start with). I will have lots of images to insert, so possibly I want some coding to take care of this.

Sign in to reply to this post

Jason ByrnesWebAssist

dont change the value being stored in the database.

use the math to change how it is displayed on the page.

for example, when you add the image size binding to your page, the code will look similar to:

<?php echo $row_recordsetName['ColumnName'?>

edit that to:

<?php echo($row_recordsetName['ColumnName'] / 1024); ?>

to convert the displayed size to kb.

Sign in to reply to this post


I rounded number with round() function.

So it was:
<?php echo $row_race2012['FileSize'] / 1024; ?> kb
---> 173.4375 kb

Now it is:
<?php echo round($row_race2012['FileSize'] / 1024); ?> kb
---> 173 kb

Thank you for your help (as always)!

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...