window.URL.createObjectURL

Table of contents

  1. 1. Summary
  2. 2. Syntax
  3. 3. Example
  4. 4. Notes
  5. 5. Browser compatibility
  6. 6. See also

Summary

Creates a new object URL, whose lifetime is tied to the document in the window on which it was created. The new object URL represents the specified File object.

Syntax

objectURL = window.URL.createObjectURL(file);
  • file is a File object indicating the file to create a object URL for.
  • objectURL is the generated object URL. The entire contents of the specified file are represented by the text of the URL.
Note: This method is prefixed in Chrome and Webkit as window.webkitURL.createObjectURL().

Notes

Each time you call createObjectURL(), a new object URL is created, even if you've already created one for the same file. Each of these must be released by calling window.URL.revokeObjectURL() when you no longer need them. Browsers will release these automatically when the document is unloaded; however, for optimal performance and memory usage, if there are safe times when you can explicitly unload them, you should do so.

Browser compatibility

  • Desktop
  • Mobile

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 8 4 --- --- Nightly build
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? ? ? ? ?

Tags (2)

Edit tags

Attachments (0)

 

Attach file