We are trying to interact with a RESTful web service that is expecting a file.
I set the field name for the data (as required by the API) and then point the file as an absolute path. When a file is sent to the server, the file name in the HTTP transaction is the complete absolute path.
This causes an API problem since the full path is then written as "FileName".
How do I get ColdFusion to report only the file name and not the full path?
We are using ColdFusion 9.
Here is CFML:
<cfhttp url="http://server/testcode" port="9876" method="post" result="Content"> <cfhttpparam type="file" name="data" file="c:\temp\testfile.txt"> </cfhttp>
Here are some examples of how HTTP interacts with various browsers:
CFHTTP 9 -------------------------------7d0d117230764 Content-Disposition: form-data; name="data"; filename="c:\temp\testfile.txt" Content-Type: text/plain This is the text, really long, well, not really. -------------------------------7d0d117230764-- IE8 -----------------------------7db370d80e0a Content-Disposition: form-data; name="FileField"; filename="C:\temp\testfile.txt" Content-Type: text/plain This is the text, really long, well, not really. -----------------------------7db370d80e0a-- Chrome 13 ------WebKitFormBoundaryDnpFVJwCsZkzTGDc Content-Disposition: form-data; name="FileField"; filename="testfile.txt" Content-Type: text/plain This is the text, really long, well, not really. Firefox 6 -----------------------------22798303036224 Content-Disposition: form-data; name="FileField"; filename="testfile.txt" Content-Type: text/plain This is the text, really long, well, not really. -----------------------------22798303036224--
Obviously, IE8 and CFHTTP do the same (add "c: \ temp" to the file name). I'm not sure what the spec is for HTTP, but it would be nice if there was a way to get CFHTTP to leave the path.
Is there any way to do this?
source share