Skip to main content
Inspiring
June 21, 2023
Answered

Coldfusion equivalent of PHP file_get_contents

  • June 21, 2023
  • 1 reply
  • 395 views

I'm trying to use Coldfusion to integrate with the Wordpress API. In order to add images through the Wordpress API, you have to include the image in the body of the post call. PHP has the file_get_contents() function, which returns the image as a string, which can then be passed in the body of the call. Does Coldfusion have a similar function that will return an image as a string?

    This topic has been closed for replies.
    Correct answer Charlie Arehart

    Are you interested in using cfhttp to get the file? If so, see its getasbinary attribute, then use the tag's result attribute as one way to refer to what is returned. Let us know if that helps or not. 

    1 reply

    Charlie Arehart
    Community Expert
    Charlie ArehartCommunity ExpertCorrect answer
    Community Expert
    June 21, 2023

    Are you interested in using cfhttp to get the file? If so, see its getasbinary attribute, then use the tag's result attribute as one way to refer to what is returned. Let us know if that helps or not. 

    /Charlie (troubleshooter, carehart. org)
    mcarlsonAuthor
    Inspiring
    June 22, 2023

    Thanks. I had tried that previously without success, but I must have done something wrong, as I was able to get it to work this time.

    Charlie Arehart
    Community Expert
    Community Expert
    June 22, 2023

    Great to hear, happy to have helped, and thanks for the update and the marking of a correct answer. 

    /Charlie (troubleshooter, carehart. org)