?
Solved

Problem using CFHTTP to post a .docx file

Posted on 2008-10-17
6
Medium Priority
?
543 Views
Last Modified: 2013-12-24
I have an application that uses a resume parsing service.  If I upload the file with a standard form, the service is able to parse the file just fine.  If I POST the file with a CFHTTP tag, the service errors out.

Is there anything further I need to do with my CFHTTP or CFHTTPPARAM tags to further mimic a "standard" form POSTing?

<html>
<head>
	<title>HTTP Post Test</title>
</head>
<body>
<h1>HTTP Post Test</h1>
 
<CFSET variables.str_url = "XxXxXxXxX">
<CFSET variables.str_did = "XxXxXxXxX">
<CFSET variables.str_pid = "XxXxXxXxX">
<CFSET variables.str_cid = "XxXxXxXxX">
<CFSET variables.str_file = "XxXxXxXxX/test5.docx">
 
<!---  This does NOT work  --->
<CFHTTP url="#variables.str_url#" method="post" redirect="yes" useragent="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)">
	<CFHTTPPARAM type="formfield" name="did" value="#variables.str_did#">
	<CFHTTPPARAM type="formfield" name="pid" value="#variables.str_pid#">
	<CFHTTPPARAM type="formfield" name="cid" value="#variables.str_cid#">
	<CFHTTPPARAM type="file" name="document" mimetype="multipart/form-data" file="#variables.str_file#">
</CFHTTP>
 
<CFOUTPUT>
<CFIF StructKeyExists(cfhttp,"filecontent")>
	#cfhttp.filecontent#
</CFIF>
 
<!---  This DOES work  --->
<form action="#variables.str_url#" method="POST" name="frmupload" enctype="multipart/form-data">
	<input type="hidden" name="did" value="#variables.str_did#">
	<input type="hidden" name="pid" value="#variables.str_pid#">
	<input type="hidden" name="cid" value="#variables.str_cid#">
	<input type="file" name="document">
	<input type="submit" name="submit_upload" value="upload">
</form>
</CFOUTPUT>
</body>
</html>

Open in new window

0
Comment
Question by:aseusainc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 25

Expert Comment

by:dgrafx
ID: 22784932
1) method needs to be "PUT"
2) Your mime type (for type=file) needs to be the mimetype of the file you are "PUTTING"
multipart/form-data is Not a mimetype
docx is "application/vnd.openxmlformats-officedocument.wordprocessingml.document"

good luck ...
0
 
LVL 7

Author Comment

by:aseusainc
ID: 22786212
Ended up using another method completely.  Resume parsing service has a SOAP web service that I was able to invoke.
0
 
LVL 25

Expert Comment

by:dgrafx
ID: 22786327
sure ok great ...
but getting back to the question you asked - what I posted is correct.
You can use it for the future when you don't have a prefab web service to rely on.

good luck ...
0
 
LVL 7

Author Comment

by:aseusainc
ID: 22786481
I still intend to go back and test that real quick.  Will post my findings soon.
0
 
LVL 7

Accepted Solution

by:
aseusainc earned 0 total points
ID: 23016950
Changing the MIME type and PUT didn't change anything.  Anyway, switched to the webservice method.

Requesting close.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question