Get the file size

Posted on 2014-07-24
Last Modified: 2014-07-24

I have a file stored in the database that I need to get the size of it.

How can I do that?

 <cfquery name = "QRmvLgFiles"  datasource='#strDSN#' username='#strUID#' password='#strPWD#'>
   Select FileID, Description, UploadedFile, Uploadedasbinary from Files
   where IssueID = #AlertIssueId#

   <cfloop query="QRmvLgFiles">

//here I need to find out what is the file size for the objects that I uploaded. 

Open in new window

Question by:lulu50
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    I presume you refer to this field:

    which is a binary field, likely.
    you could simply get the binary field size by the relevant database function.
    you can check the technical documentation of your rdbms, or tell us which db type you are using.
    usualy it's a function with LEN, LENGTH in the name, or LENB for length in bytes...
    LVL 39

    Accepted Solution

    What database are you using and what is the data type of the column

    In the future, I suggest adding a field to your table for FileSize, then when you upload a new file, you can save the size of the file very easily.   To get the size of the file during upload, just use   CFFILE.FileSize  and save it.     This will allow you to query for the largest files or tell a user their total file size very easily.

    Author Comment


    Thank you that's a great idea!!!!

    Author Closing Comment


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math ( While this method is not o…
    This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now