Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Re: binary data in a form field gets changed

$
0
0

Ah, I had assumed the form is on your site. Your answer suggests otherwise.

 

In any case, it seems there are at least 2 form fields coming in, a binary (file) and plain text. You could just treat the form post as an upload. If you know the MIME type of the binary, then you could capture it and store it as a file.

 

Here follows a simple example in which I upload a PDF file (a binary) and some text. Ignore the fact that it is in Windows. What you are interested in are the 2 cffile tags. In your case, fileField = "Userdata" and output="#form.field#"

 

<cfif isDefined("Form.FileContents") >

 

   <cffile action = "upload"

       strict="false"

        fileField = "FileContents"

        destination = "c:\temp\upload\uploadFile.pdf"

        accept = "application/pdf, binary/octet-stream"

        nameConflict = "MakeUnique">

       

   <cffile action="write" file="c:\temp\upload\uploadTxt.txt" output="#form.txtContent#">

 

Done uploading

<cfelse>

    <form method="post" action=<cfoutput>#cgi.script_name#</cfoutput>

        name="uploadForm" enctype="multipart/form-data">

        <input name="FileContents" type="file">

         <input name="txtContent" type="text">

        <br>

        <input name="submit" type="submit" value="Upload File">

    </form>

</cfif>


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>