Skip to main content
Known Participant
March 1, 2011
Question

Time cffile upload

  • March 1, 2011
  • 2 replies
  • 1048 views

Hi everyone,

I want to time the upload time when using CFFILE

I thought I could take the tome before the cffile tag and then take the time after the cffile tg and use the Datediff to get the upload time in seconds. See example below.  But this gives me 0 seconds.

------------- Example ------------

<cfset startTime = Now()>

<cffile action="upload" destination="#application.upload_images#"  filefield="#variables.filename#" nameconflict="MakeUnique" accept="image/jpg,image/jpeg,image/pjpeg">

<cfset endTime = Now()>

<cfset uploadTime = DateDiff("s", startTime, endTime)>

---------------------------------------

How can I time the upload time?

Thanks!

    This topic has been closed for replies.

    2 replies

    Community Expert
    March 1, 2011

    The CFFILE tag that processes the upload doesn't actually have anything to do with receiving the file. By the time CF runs, the request has already been received in full by the web server.

    So, you need to do your timing from the client in this case, not the web server. There are plenty of timing tools for Firefox and presumably Chrome as well. Load test tools do client-side timing as well.

    Dave Watts, CTO, Fig Leaf Software

    http://www.figleaf.com/

    http://training.figleaf.com/

    Dave Watts, Eidolon LLC
    Owainnorth
    Inspiring
    March 1, 2011

    Use getTickCount(), it's a lot simpler.

    <cfset startTime = getTickCount() />

    Do stuff

    <cfoutput>#getTickCount()-startTime</cfoutput>ms

    Known Participant
    March 1, 2011

    Thanks for pointing out the getTickCount() function, never heard of it.... but very handy!

    Unfortunatly it doesn't solve my problem with the timing, I still get 0 seconds or ms

    Owainnorth
    Inspiring
    March 1, 2011

    Ah, bear in mind it's not doing what you think it's doing.

    The <cffile> tag is *not* uploading the file, by the time it's called the file has already been uploaded to the Web Server, cffile is simply moving the file to its destination, which is probably taking less than a millisecond and so showing as zero.

    There are many threads on here about creating timers for uploads, and due to various technical reasons it's nowhere near as simple as you'd like I'm afraid