4

I found a web-site that clears exif data from an image. The source can either be an uploaded picture or a URL. I thought, perhaps, I could use this with CFHTTP to do this automatically for pictures I post to my web-site. I know I can probably run my images manually through this site before I upload them to my site. Call this an exercise if you want.

Here is the code I am using, which basically matches the form source on this very simple web-site (link)

<cfhttp method="POST" url="https://www.verexif.com/en/quitar.php" result="result"  >
    <cfhttpparam name="foto_url" type="formfield" value="{myimageurl}">
</cfhttp>

When I CFDUMP the result, I get the following: CFDUMP of CFHTTP Result

When I try to use DeserializeJSON(result.Filecontent), it gives me a ColdFusion error:

ColdFusion error

When I url-encode my original URL in the CFHTTP tag, the result.filecontent contains the source code of the original web-site.

As can be seen in the first image above, there is a file called 'foto_no_exif.jpg' included in the output. This is the file I need to download. How can I do this ?

Richard Martin
  • 131
  • 1
  • 9
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/182374/discussion-between-richard-martin-and-shawn). – Richard Martin Oct 23 '18 at 16:36

1 Answers1

3

In your current dump, you have the modified image, but you need to get to accesses it as binary data. You can force the file content of the request to be treated as binary data by adding the attribute getasbinary to your cfhttp tag.

Working example:

<cfset imageURL ='https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/long_description.jpg'/>
<cfhttp method="get" getasbinary="yes" charset="utf-8" url="https://www.verexif.com/en/quitar.php" result="result">
    <cfhttpparam name="foto_url" type="formfield" value="#imageURL#">
</cfhttp>
<cfcontent variable="#result.Filecontent#" type="image/jpg" reset="true" />

Run it on TryCF.com

Twillen
  • 1,458
  • 15
  • 22
  • Thank you Twillen. As you can see on my second-to-last comment above, it was a filename issue that was causing a lot of my problems. Thank you though! – Richard Martin Oct 23 '18 at 16:02
  • 3
    @RichardMartin Yes, that why it is important to create a complete working example that demonstrates the error your currently getting. It'll help you isolate the issue at hand. If you had isolated out your url earlier, you may have noticed the filename / url issue sooner. – Twillen Oct 23 '18 at 16:09