<cfif not isdefined("FORM.EventAction")>
<table border="0" align="center" width="90%" cellspacing="0"
cellpadding="0" STYLE="Border-Color: 000000; Border-Style: solid;
Border-Width: 0px;">
<tr>
<td Class="ErrorMsgDetails">Select File to Upload</td>
</tr>
<tr>
<td Class="ErrorMsgDetails"> </td>
</tr>
<tr>
<td Class="ErrorMsgDetails">
<cfoutput>
<form action=""
method="post" name="UploadForm" enctype="multipart/form-data">
<input type="Hidden" Name="EventAction" Value="File Selected">
<input type="file" name="UploadedFile" size="40"
maxlength="100"> <input type="submit" value="UPLOAD FILE"> </form>
</cfoutput>
</td>
</tr>
</table>
</cfif>
<cfif isdefined("FORM.EventAction")>
<cfswitch _expression_="#FORM.EventAction#">
<cfcase value="File Selected">
<cfset path =
#GetDirectoryFromPath(GetCurrentTemplatePath())#>
<cffile action="" filefield="Form.UploadedFile"
destination="#variables.path#" nameconflict="OVERWRITE">
<cffile action=""
file="#variables.path#\#cffile.ClientFileName#.#cffile.ClientFileExt#"
variable="variables.FileContent">
<cfset Form.Delims = "#chr(13)#" & "#chr(10)#">
<cfset Form.FileSize = #Len(variables.FileContent)#>
<cfset Form.FileLines = #ListLen(Variables.FileContent,
Form.Delims)#>
<cfset variables.FileContent =
#Replace(variables.FileContent, ",,", ", ,", "all")#>
<cfset variables.Filecontent =
#Replace(variables.FileContent, ",,", ", ,", "all")#>
<cfset FileContentLines =
#ListToArray(variables.FileContent, Form.Delims)#>
<cfset FileContentLength =
#ArrayLen(variables.FileContentLines)#>
<cfset FieldNameList = #variables.FileContentLines[1]#>
<cfset FieldQnty = #ListLen(Variables.FieldNameList, ",")#>
<cfset FieldNameArray =
#ListToArray(variables.FieldNameList, ",")#>
<!--- Set Column Name Variables to 0 --->
<cfset COLHeader1 = "0">
<cfset COLHeader2 = "0">
<cfset COLHeader3 = "0">
<cfset COLHeader4 = "0">
<cfset COLHeader5 = "0">
<cfset COLHeader6 = "0">
<cfset COLHeader7 = "0">
<cfset COLHeader8 = "0">
<cfset COLHeader9 = "0">
<cfloop index="FieldCounter" from="1"
to="#variables.FieldQnty#" step="1">
<cfif #variables.FieldNameArray[variables.FieldCounter]#
Contains "Corp">
<cfset COLHeader1 = #variables.FieldCounter#>
</cfif>
<cfif #variables.FieldNameArray[variables.FieldCounter]#
Contains "SCHLNumber">
<cfset COLHeader2 = #variables.FieldCounter#>
</cfif>
<cfif #variables.FieldNameArray[variables.FieldCounter]#
Contains "SCHLName">
<cfset COLHeader3 = #variables.FieldCounter#>
</cfif>
<cfif #variables.FieldNameArray[variables.FieldCounter]#
Contains "LADDRESS">
<cfset COLHeader4 = #variables.FieldCounter#>
</cfif>
<cfif #variables.FieldNameArray[variables.FieldCounter]#
Contains "LCITY">
<cfset COLHeader5 = #variables.FieldCounter#>
</cfif>
<cfif #variables.FieldNameArray[variables.FieldCounter]#
Contains "STATE">
<cfset COLHeader6 = #variables.FieldCounter#>
</cfif>
<cfif #variables.FieldNameArray[variables.FieldCounter]#
Contains "LZIP">
<cfset COLHeader7 = #variables.FieldCounter#>
</cfif>
<cfif #variables.FieldNameArray[variables.FieldCounter]#
Contains "PHONE">
<cfset COLHeader8 = #variables.FieldCounter#>
</cfif>
<cfif #variables.FieldNameArray[variables.FieldCounter]#
Contains "FAX">
<cfset COLHeader9 = #variables.FieldCounter#>
</cfif>
</cfloop>
<cfloop index="FileProcess" from="2"
to="#variables.FileContentLength#" step="1">
<cfset FieldDataArray =
#ListToArray(FileContentLines[variables.FileProcess], ",")#>
<cfset COLData1 = #FieldDataArray[variables.COLHeader1]#>
<cfset COLData1 = #Mid(Variables.ColData1, 2,
LEN(Variables.ColData1) - 2)#>
<cfset COLData2 = #FieldDataArray[variables.COLHeader2]#>
<cfset COLData2 = #Mid(Variables.ColData2, 2,
LEN(Variables.ColData2) - 2)#>
<cfset COLData3 = #FieldDataArray[variables.COLHeader3]#>
<cfset COLData3 = #Mid(Variables.ColData3, 2,
LEN(Variables.ColData3) - 2)#>
<cfset COLData4 = #FieldDataArray[variables.COLHeader4]#>
<cfset COLData4 = #Mid(Variables.ColData4, 2,
LEN(Variables.ColData4) - 2)#>
<cfset COLData5 = #FieldDataArray[variables.COLHeader5]#>
<cfset COLData5 = #Mid(Variables.ColData5, 2,
LEN(Variables.ColData5) - 2)#>
<cfset COLData6 = #FieldDataArray[variables.COLHeader6]#>
<cfset COLData6 = #Mid(Variables.ColData6, 2,
LEN(Variables.ColData6) - 2)#>
<cfset COLData7 = #FieldDataArray[variables.COLHeader7]#>
<cfset COLData7 = #Mid(Variables.ColData7, 2,
LEN(Variables.ColData7) - 2)#>
<cfset COLData8 = #FieldDataArray[variables.COLHeader8]#>
<cfset COLData8 = #Mid(Variables.ColData8, 2,
LEN(Variables.ColData8) - 2)#>
<cfset COLData9 = #FieldDataArray[variables.COLHeader9]#>
<cfset COLData9 = #Mid(Variables.ColData9, 2,
LEN(Variables.ColData9) - 2)#>
<cfquery name="InsertRecord" datasource="OnlineRegistration">
Insert into schoolbuildings(CorpNumber,
SchoolNumber, SchoolName, SchoolAddress, SchoolCity, SchoolState,
SchoolZipCode, SchoolPhone, SchoolFax)
Values('#variables.COLData1#',
'#variables.COLData2#', '#variables.COLData3#', '#variables.COLData4#',
'#variables.COLData5#', '#variables.COLData6#', '#variables.COLData7#',
'#variables.COLData8#', '#variables.COLData9#')
</cfquery>
</cfloop>
</cfcase>
</cfswitch>
</cfif>
At 07:12 AM 10/15/2004, you wrote:
>Here is how I do it through Coldfusion and have not had any problems with
>it. Basically I ask the user to sleect their file through a Form Object,
>and The CFFile to Upload this file and then to read the file uploaded. Next
>I create Objects and Reach each line into an Array. I then have a section
>to read the first line of the array and set variables for the specific
>header fields that I want to import. Last I loop over the Length of the
>array and Insert it into the datasource/table that I need it to go into.
>
>At 06:33 AM 10/15/2004, you wrote:
> >My question exactly! Especially since the DB isnt on the same server
> >(as they generally shouldnt be!)
> >
> >MD
> >
> >----------
> >[<http://www.houseoffusion.com/lists.cfm/link=t:4>Todays Threads]
> >[<http://www.houseoffusion.com/lists.cfm/link=i:4:181581>This Message]
> >[<http://www.houseoffusion.com/lists.cfm/link=s:4>Subscription]
> >[<http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=6232.5677.4>
> Fast
> >Unsubscribe] [<http://www.houseoffusion.com/signin/>User Settings]
> >[<https://www.paypal.com/cgi-bin/webscr?amount=&item_name=House+of+Fusion
> &business=donations%40houseoffusion.com&undefined_quantity=&cmd=_xclick>Donations
>
> >and Support]
> >
> >----------
> ><http://www.houseoffusion.com/banners/view.cfm?bannerid=34>
> >[]
> >
>
>----------
>[]
>
>----------
>[<http://www.houseoffusion.com/lists.cfm/link=t:4>Todays Threads]
>[<http://www.houseoffusion.com/lists.cfm/link=i:4:181586>This Message]
>[<http://www.houseoffusion.com/lists.cfm/link=s:4>Subscription]
>[<http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=6232.5677.4>Fast
>Unsubscribe] [<http://www.houseoffusion.com/signin/>User Settings]
>[<https://www.paypal.com/cgi-bin/webscr?amount=&item_name=House+of+Fusion&business=donations%40houseoffusion.com&undefined_quantity=&cmd=_xclick>Donations
>and Support]
>
>----------
><http://www.houseoffusion.com/banners/view.cfm?bannerid=36>
>[]
>
----------
[]
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

