views:

48

answers:

2

We're using GWT and want to download an image to the client, then send this image to another server using a POST request...

A JavaScript/AJAX solution would be helpful too.

Is this plausible? Can a web app access cached images from the client's browser?

We're rookies, if this is futile please let us know. Thanks!

UPDATE: We abandoned this approach. After doing some research it seems that the only way one can set a multipart body request is through an HTML form, even then the client has to specify what file she wants uploaded. It makes perfect sense from a security standpoint. What we were trying to do was basically route an image image from server to client to server... thanks for the help.

A: 

Ajax, or asynchronous get/post cannot cross domains. You can only achieve this by having a hidden form, modifying the action parameter, and then using javascript to execute the submit on that form.

I'm sorry to say, I don't know how to go about that in GWT (been a long time since i used it), but that's the algorithm.

Aren
So does it sound impossible to have a GET request that brings an image to the client, and then if the user chooses to, send that same image as part of the multipart/form-data of the POST request to a different server than the one the image came from?
Diego
+2  A: 

You could use a privileged Applet or Flash, but basic JavaScript won't do it.

Or maybe just send the image URL to the foreign server with JSONP and let that server download the image itself?

Isaac Truett
+1 for the image URL + JSONP idea - GWT even has a `JsonpRequestBuilder` for your convenience :)
Igor Klimer
I have no control over the remote server, I don't think the remote server will fetch a URL. I'm supposed to include the image in the multipart/form-data part of a POST request... I think Aren B is closer to the answer, but then again I don't have much experience...
Diego