Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Use getTickCount(), it's a lot simpler.
<cfset startTime = getTickCount() />
Do stuff
<cfoutput>#getTickCount()-startTime</cfoutput>ms
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 ![]()
Copy link to clipboard
Copied
![]()
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!!
Copy link to clipboard
Copied
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 ![]()
Copy link to clipboard
Copied
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/
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more