• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

problem getting cffile.timecreated from cffile upload

The code is added to the message

As you can tell, the part of code that requests "cffile.timecreated" is only called if the cffile.serverfile exists, which means its getting uploaded, and the file shows up in the directory is supposed too, but the cffile.timecreated value is coming back empty. Can someone look at the code and tell me if there is anything wrong?
 
Try using cffile.timecreated instead of file.timecreated.

A couple of other suggestions:

1. Wrapping your <cffile> tag in a <cflock> is unnecessarily inefficient. Copy your session variable to a local scope variable in the <cflock>, then perform the <cffile> afterwards:

<cflock scope="session" timeout="10" type="readonly">
....<cfset MySessionId = Session.id>
</cflock>

<CFFILE Action="upload"
destination="C:\inetpub\wwwroot\imagehost\#MySessionId#"
ACCEPT="image/jpg, image/pjpeg, image/gif, image/bmp, image/tiff"
nameconflict="makeunique"
filefield="photo_1">

2. Don't use a cflock timeout of 1. You're bound to run into errors.
3. Why are you wrapping everything in a <cftransaction> tag? <cftransaction> is only used for multiple database queries.
 
ok, well i set the session.id to a local scope variable, removed the transaction tags and cflock tags, and locked the code the sets the session.id to just id.

still getting the error

i dont know, sometimes it will give me the value and sometimes it doesn't. im at a loss with this.....
 
An error occurred while evaluating the expression:


local_photo_file_created_1 = #CreateODBCDateTime(cffile.timecreated)#



Error near line 1014, column 7.
--------------------------------------------------------------------------------

Parameter 1 of function CreateODBCDateTime which is now "" must be a date/time value
Detail:
 
Originally posted by: TechBoyJK
ok, well i set the session.id to a local scope variable, removed the transaction tags and cflock tags, and locked the code the sets the session.id to just id.

still getting the error

i dont know, sometimes it will give me the value and sometimes it doesn't. im at a loss with this.....

Is the <cffile> code being executed simultaneously by multiple users? The property could be overwritten before the cffile.timeCreated line gets executed.
 
i am still developing it, so im the only one using it. i even have public access blocked off at the firewall.

for instance

<CFIF (isDefined("FORM.photo_3") AND FORM.photo_3 NEQ "")>
<CFFILE Action="upload"
destination="C:\inetpub\wwwroot\imagehost\#id#"
ACCEPT="image/jpg, image/pjpeg,image/gif,image/bmp, image/tiff"
nameconflict="makeunique"
filefield="form.photo_3">
<CFSET local_photo_file_3 = '#cffile.serverfile#'>
<cfoutput>#cffile.serverfile#
</cfoutput>
<CFSET local_photo_file_created_3 =#CreateODBCDateTime(cffile.timeCreated)#>
</CFIF>


One, the file gets to the directory, however, when I try and use the cffile.serverfile value it returns a null value ""

If you notice the cfoutput tag, it will display the uploaded filename in the browser, but crashes on the next tag, which is the tag that uses the timecreated variable.

I dont have a clue.
 
Originally posted by: MrChad
Originally posted by: TechBoyJK
ok, well i set the session.id to a local scope variable, removed the transaction tags and cflock tags, and locked the code the sets the session.id to just id.

still getting the error

i dont know, sometimes it will give me the value and sometimes it doesn't. im at a loss with this.....

Is the <cffile> code being executed simultaneously by multiple users? The property could be overwritten before the cffile.timeCreated line gets executed.

thats why i was using the transaction tag, i thought it would prevent that
 
Originally posted by: TechBoyJK
One, the file gets to the directory, however, when I try and use the cffile.serverfile value it returns a null value ""

If you notice the cfoutput tag, it will display the uploaded filename in the browser, but crashes on the next tag, which is the tag that uses the timecreated variable.

I dont have a clue.

😕

So does CFFILE.ServerFile work consistently? Or is it intermittent like CFFILE.timeCreated?
 
Originally posted by: TechBoyJK
thats why i was using the transaction tag, i thought it would prevent that

No, <cftransaction> is ONLY for db transactions. You could try an exclusive named lock, but I'm not sure if that would work (plus it could have a significant impact on performance if your load is high).
 
Originally posted by: MrChad
Originally posted by: TechBoyJK
One, the file gets to the directory, however, when I try and use the cffile.serverfile value it returns a null value ""

If you notice the cfoutput tag, it will display the uploaded filename in the browser, but crashes on the next tag, which is the tag that uses the timecreated variable.

I dont have a clue.

😕

So does CFFILE.ServerFile work consistently? Or is it intermittent like CFFILE.timeCreated?

works always, but as soon as I try and call the timecreated variable, it returns nothing.....
 
I'm stumped. You might want to try Macromedia's forums to see if any of their guys can provide assistance.

Sorry 🙁
 
well,

i found a way to get it to work, but it is by no way a true functional approach. If I submit the upload form, i will get the error, even though the file got uploaded. If i click back on the browser, and try it again, with the same file, it will work. Please note, that i have the cffile tag set to "makeunique" So what happens is, the original photo gets to the directory, but cffile wont output the timecreated variable. When I go back and resubmit the same photo, it will upload it again, make it a unique filename, and then output the timecreated. WTF?!?!?!?! I end up with the original and the duplicate w.unique filename in the directory. Could it be possible that it tries setting the local scope variable to cffile.timecreated before the file is finished uploading? Maybe it doesn't have that value yet, as I try setting the local scope variable immediately after the tag. Maybe the second time around is actually getting the original timecreatedvalue......????? This seems logical, but I don't know how cffile works at that level.... I've found nothing of this kind of problem on google, yahoo, anything, and I've spent all day looking. I'm going to hit borders tomorrow and read through some cf books, but I'm afraid they won't say much more than Macromedia's livedocs, or forta's faqs...

I'm going to get a better disertation together for this one, try some more cases, try and narrow it down..... I need this to work, no way around it. I've tried restarting the server, as well as cfserver. Nothing fixes it. But it works the way I described it above.
 
Back
Top