simon simon - 9 months ago 75
Javascript Question

JavaScript: can I read EXIF data from a file upload input?

I have the following task:

  • Offer an
    <input type=file />

  • When the user adds a file:

    • read the EXIF data (specifically, location information if available)

    • send the file and the information from the EXIF to an external API, using Ajax

So, I'd like to use JavaScript to extract some EXIF data when a file is added to the

Is this possible?

I know about this question: Can I read Exif data of a picture in the client-side with js ? , which refers to

But my question is (I think?) slightly different - I want to extract the EXIF data before the image is even on my domain, while it's on the user's local filesystem, if you see what I mean. I can access the binary data, so can I get the EXIF too?

Thanks for your advice.

Answer Source

No, sorry. You can't access any of the file data until it's uploaded to the server, which is certainly what the library you linked to does. Once the file is uploaded, you can save it somewhere, re-download it and read EXIF data from it.

The above answer used to be correct, but most modern browsers now allow file access via the js file apis. Feel free to use that, but you should also use a server-side solution if cross-browser support is required.