Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Time cffile upload

New Here ,
Mar 01, 2011 Mar 01, 2011

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!

1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 01, 2011 Mar 01, 2011

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

<cfset startTime = getTickCount() />

Do stuff

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2011 Mar 01, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 01, 2011 Mar 01, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 01, 2011 Mar 01, 2011

Ok thank you for your reply. I was also thinking in that direction but was hoping it was as simple as I initially thought.

I gues the uploading starts straight after clicking on the submit button on the upload form. O well it was not an important feature needed, just thought it would be interesting to monitor the upload times of users.

Thanks for your help!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 01, 2011 Mar 01, 2011
I guess the uploading starts straight after clicking on the submit button on the upload form.

Spot on, CF doesn't even get a look in until the upload has actually finished.

Glad to save you some time, if nothing else

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 01, 2011 Mar 01, 2011
LATEST

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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources