I'm a newbie on coldfusion so please someone help me.

<CFset today = NOW()>

<cfif not isDefined("Form.fileupload") OR Form.fileupload EQ "">
   <cfquery datasource = "technology">
       INSERT INTO sharex_2007
       VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)

    </cfquery>

<cfelseif>
     <cffile action="upload"
     filefield="fileupload"
     destination="d:\intranet_info\sharing\shared_x\newsharex\2007\"
nameconflict="overwrite">

<cfquery datasource = "technology">
       INSERT INTO sharex_2007
       VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)

    </cfquery>

<cfelseif>
     <cffile action="upload"
     filefield="fileupload"
     destination="d:\intranet_info\sharing\shared_x\newsharex\2007\"
nameconflict="overwrite">

<cfquery datasource = "technology">
       INSERT INTO sharex_2007
       VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)

    </cfquery>

</cfif>

Recommended Answers

All 3 Replies

elseif implies that you have multiple conditions to check. Example:

<cfif color is "green">
     <cfset colorscheme = "white">
<cfelseif color is "blue"><!---Notice how there is a statement after elseif. You can't just use <cfelseif>--->
     <cfset colorscheme = "black">
<cfelse>
     <cfset colorscheme = "red">
</cfif>

Honestly, you have two elseif statements that do the exact same thing. In that case, you could just use else and get rid of the second elseif:

<cfset today = NOW()>

<cfif not isDefined("Form.fileupload") OR Form.fileupload EQ "">
<cfquery datasource = "technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)
</cfquery>

<cfelse>
<cffile action="upload"
filefield="fileupload"
destination="d:\intranet_info\sharing\shared_x\newsharex\2007\"
nameconflict="overwrite">

<cfquery datasource = "technology">
INSERT INTO sharex_2007
VALUES('#Form.title#', #CreateODBCDateTime (Form.date#, '#Form.presenter#', '#Form.group#', '#Form.remarks#', '#Form.ClientFile#', #Form.audience#)

</cfquery>
</cfif>

Also, to keep things neat in the future, wrap your code in code tags like so:

[code=Coldfusion] <cfset var = 2>

[/code]

And it will look like this:

<cfset var = 2>

I'm a newbie on coldfusion so please someone help me.
Sorry i type it wrong. The linking part should be ..\newsharex\2007 and ..\newsharex\2008 What i want is that i need to upload(ms excel, pdf, word files etc) to differerent folders (example: year2007, year2008) in the server and store the image names, paths in a database table

Well you have to come up with some type of criteria for the script to decide which folder to choose.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.