Reading and parsing a text file

Results 1 to 4 of 4

Thread: Reading and parsing a text file

  1. #1
    Josh Rolfe Guest

    Default Reading and parsing a text file

    Here is what I am trying to do:<BR>1 - The user uploads a file using a file input element<BR>2 - Cold Fusion uses a "makeunique" method to uniquely label the file and write it to the server.<BR>3 - The file is parsed, getting the appropriate information into variables<BR>4 - The information is written to a database.<BR><BR>Here is my problem:<BR>I would like to use ASP to parse the text file, but ASP runs before the page loads and the file doesn&#039t exist until Cold Fusion gives it a unique file name and writes it to the server, which happens when the action page loads, AFTER the asp runs. So ASP can&#039t parse the file until it exists. It is a chicken and the egg problem. I thought about using client-side javascript to parse the text file, because that would run after the filename is assigned by cold fusion, but as far as I know, there is no way to open and parse a text file into variables off the server using javascript...or is there?

  2. #2
    Markkk Guest

    Default HTML  -to-  CFM  -to-  ASP

    Create a HTML or ASP page to collect the File Form data:<BR><BR>e.g.<BR>&#060;form ENCTYPE="multipart/form-data" ACTION="SaveFile.cfm" METHOD="post"&#062;<BR>&#060;input TYPE="file" NAME="reportfilename" Size="50" ACCEPT="*/*"&#062;<BR>&#060;input type="submit" value="Submit" name="SubmitButton"&#062;<BR>&#060;/form&#062;<BR><BR><BR>In the SaveFile.cfm file, save the uploaded file using normal CFM Tags, and pass whatever data you like to an ASP page, via querystring variables, for further processing (e.g. text parsing into your database).<BR><BR>e.g. similar to:<BR><BR>&#060;CFFILE ACTION="UPLOAD" FILEFIELD="reportfilename" DESTINATION="D:FileUploads\" NAMECONFLICT="OVERWRITE" ACCEPT="*/*"&#062;<BR><BR>&#060;CFSET ReportFileName = #File.ClientFile#&#062; <BR>&#060;CFSET REMOTE_HOST = #cgi.REMOTE_HOST#&#062;<BR><BR>&#060;CFSET SaveReportURL = "ParseText.asp?FileName=" & #File.ClientFile# & "&RemoteHost=" & #cgi.REMOTE_HOST#&#062;<BR><BR>&#060;CFLOCATION URL = "#SaveReportURL#"&#062;<BR><BR>**NOTE**<BR>The above CFM tags aren&#039t totally correct (my CFM tag background is somewhat limited).....but you get the idea.<BR><BR><BR>I hope this helps!!<BR>

  3. #3
    Josh Rolfe Guest

    Default RE: HTML *-to- *CFM *-to- *ASP

    Thanks a ton. I figured I was going to have to do something like that. Your sample code helps a lot.<BR>Thanks.

  4. #4
    lagerBoy Guest

    Default Thanks

    This helped with a problem I was having too, thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts