Skip to main content
Inspiring
Jun 21, 2023 4:53 PM UTC
Answered

Coldfusion equivalent of PHP file_get_contents

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 is closed to new replies. Start a new post to keep the conversation going.
    Charlie Arehart
    Charlie ArehartCorrect answer
    Community Expert
    Jun 21, 2023 5:11 PM UTC

    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)

    3 replies

    Charlie Arehart
    Community Expert
    Charlie ArehartCommunity ExpertCorrect answer
    Community Expert
    Jun 21, 2023 5:11 PM UTC

    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. 

    Translate
    /Charlie (troubleshooter, carehart. org)
    mcarlsonAuthor
    Inspiring
    Jun 22, 2023 4:15 PM UTC

    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.

    Translate
    Charlie Arehart
    Community Expert
    Community Expert
    Jun 22, 2023 5:28 PM UTC

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

    Translate
    /Charlie (troubleshooter, carehart. org)