<cfset arrErrors = [] />
<chain:steps>
<chain:try>
<cffile
action="upload"
filefield="resume"
destination="#REQUEST.UploadDirectory#"
nameconflict="makeunique"
/>
<cfif (ListLast( CFFILE.ServerFile, "." ) NEQ "csv")>
<chain:throw
type="File.InvalidExtension"
message="File extension was not valid"
detail="The file you uploaded was not valid. Only CSV files can are allowed."
/>
</cfif>
<chain:catch>
<cfset ArrayAppend(
arrErrors,
"There was a problem uploading the file."
) />
</chain:catch>
</chain:try>
<chain:try>
<cfset qData = ProcessUpload(
"#REQUEST.UploadDirectory##CFFILE.ServerFile#"
) />
<chain:catch>
<cfset ArrayAppend(
arrErrors,
"There was a problem importing the data file."
) />
</chain:catch>
</chain:try>
<chain:try>
<cfloop query="qData">
<cfquery name="qInsert" datasource="test">
INSERT INTO [table]
(
[value]
) VALUES (
#qData.value#
);
</cfquery>
</cfloop>
<chain:catch>
<cfset ArrayAppend(
arrErrors,
"There was a problem inserting the data. Perhaps some of your values were not valid."
) />
</chain:catch>
</chain:try>
<chain:catch>
<cfset LogError( CFCATCH ) />
</chain:catch>
</chain:steps>