Remote file upload with Javascript

Asked

Viewed 63 times

0

It is possible to make a request POST sending a file as parameter?

For example the website of Tinypic contains a field of the type file, and I want to send a direct image of my application to Tinypic.

1 answer

0


Yes, it is possible to make POST requests by Javascript using Xmlhttprequest, alias AJAX.

However, it is not possible to send an image to Tinypic that way, because it features Cross-Site Scripting (XSS): you are trying to post a form from an A domain (your website) to a B domain (tinypic). This could only happen if Tinypic included your domain in the header X-Allow-Origin.

There is the possibility to upload images pro Tinypic from your site by service plugin. They put an iframe on your page, then it works, because inside the iframe there is a page with the domain tinypic.com.

  • Thanks, clarified my doubt! @rodorgas

Browser other questions tagged

You are not signed in. Login or sign up in order to post.