Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6556353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:56:03+00:00 2026-05-25T12:56:03+00:00

We are trying to interact with a RESTful web service that expects a file.

  • 0

We are trying to interact with a RESTful web service that expects a file.

I set the name of the field to data (as required by the API) and then specify the file as an absolute path. When the file makes it to the server, the filename in the HTTP transaction is the complete absolute path.

This causes a problem with the API as the full path is then recorded as the “FileName”.

How do I get ColdFusion to report only the file name rather than the full path?

We are using ColdFusion 9.

Here is the 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 the HTTP interactions with different 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--

Apparently IE8 and CFHTTP both do the same thing (add “c:\temp” to the file name). I’m not sure what the spec for HTTP is, but it would be nice if there was a way to get CFHTTP to leave the path off.

Is there any way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:56:04+00:00Added an answer on May 25, 2026 at 12:56 pm

    I ran into a problem similar to yours, once. I didn’t care about excluding the path, but I wanted to send a different filename than the name of the file on my server’s filesystem. I could not find a way to do it using CF tags at all, but I was able to get it to work by dropping into Java. I used org.apache.commons.httpclient, which ships with CF9 IIRC. It goes something like this (pardon any typos, I’m transposing from more complicated code):

    oach = 'org.apache.commons.httpclient';
    oachmm = '#oach#.methods.multipart';
    method = createObject('java', '#oach#.methods.PostMethod').init(post_uri);
    filePart = createObject('java', '#oachmm#.FilePart').init(
      'fieldname',
      'filename',
      createObject('java', 'java.io.File').init('filepath')
    );
    method.setRequestEntity(
      createObject('java', '#oachmm#.MultipartRequestEntity').init(
        [ filePart ],
        method.getParams()
      )
    );
    status = createObject('java', '#oach#.HttpClient').init().executeMethod(method);
    method.releaseConnection();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background I am trying to implement a RESTful web service using Apache-CXF that interacts
I am trying to build a web service to interact with a mobile application
I'm trying to write a simple web service client to interact with my simple
I am trying to create a java program that will interact with jUDDI to
I'm trying to use net/http to interact w/ the Yahoo Placemaker API but I
I'm trying to track how visitors interact with the price calculator that i placed
I'm using Mechanize to interact with a few web pages, and I'm trying to
I'm trying to figure out what are the layers that a web application needs
What I am trying to do is create a set of alfresco web scripts
I am trying to write tests that interact with GDB but am having trouble

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.