tags:

views:

48

answers:

1

I am using CF-8,windows-XP and IE 5.5.

I am using simple tag namely . but the output i am getting is pure gibberih along witht the text of the file(word document)

upld.cfm

   <cffile action="read" file="C:\ColdFusion8\wwwroot\Proj\updl\fileDisk\SOL.doc" variable="fileDisk"   >
          <cfoutput>#fileDisk#
         </cfoutput>

<cfoutput>
<form  name="upload" method="post" action="actionUpld.cfm?form_Num=#form_Num#" enctype="multipart/form-data">

<input name="uplForm" id="uplForm" type="file" >
<input type="submit" name="submitUpld" value="Save" onclick="" >

</form>
</cfoutput>

actionUpld.cfm

<cftry>
<cfscript>         
             newUPL = CreateCFC('cfcs.projDB');     
             newUPL.Implementation_Num =    url.form_Num;
             newUPL.uplForm = form.uplForm;
             newUPL.putUPL();        
</cfscript>
 <cfcatch type="any" >
        <cfoutput >
            <hr>
             <h4>Other Error: #cfcatch.Type#</h4>
                <li><b>Message:</b> #cfcatch.Message#
                <li><b>Detail:</b> #cfcatch.Detail#
                <li><b>Error Code:</b> #cfcatch.ErrorCode#
           </cfoutput>
       </cfcatch>
</cftry>
<cflocation url="upld.cfm??form_Num=#form_Num#" >

How best to use the cffile to output the file ?

Also when i look at the DB, i am getting the file name as

"C:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\qeq344.tmp"
How to correct it?

Is there any better way.

+1  A: 

Also when i look at the DB, i am getting the file name as C:\ColdFusion8\runtime\servers\coldfusion\SERVER-INF\temp\wwwroot-tmp\qeq344.tmp

That is a temporary file name assigned to newly uploaded files. On your action page, you need to use cffile action="upload" ... to move that temporary file to the desired location. That will populate a structure called CFFILE with details about the uploaded file, such as CFFILE.serverFile and CFFILE.serverDirectory. (Or use the "result" attribute to output the details to whatever structure name you choose.)

How best to use the cffile to output the file ?

You cannot display binary files (like *.doc) with cfoutput. To display/download such files in a browser use cfcontent

Leigh
when i am using <cfcontent > in the "upld.cfm" , to dispaly the saved attachment results , "cfcontent/download the file" is initiating first and it does not allow the whole page to display
Fransis
Yes, you cannot do both on the same page. (Not without embedding or possibly iframes). The reason is a page can only have one (1) content type. ie It can either be a word document ("application/msword") or "text/html", but not both. So your cfcontent causes the rest of the text/html in the page to be ignored. If you want to display other html, put the cfcontent in a separate script and link to it from your main page.
Leigh