Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage image pasting from clipboard in html5?

Tags:

html

On Documentum Eroom App, IE is capable of automatically uploading image from clipboard pasting whereas Firefox can't.

So I wonder if html5 supports that kind of behavior (not just drag and drop of image/file from explorer).

Update: granting access is not enough it's also about being able to handle BINARY data not just TEXT does current firefox can handle binary I can't see it maybe it's not explicit ?

It's not about just drag and drop which is widely already implemented on many sites. It's about BINARY FORMAT CLIPBOARD MANIPULATION to save the image from the clipboard to the server without any need to save file and then drag and drop. The process to save the file somewhere is extremely daunting for user so direct uploading from clipboard is really a must time saver.

like image 575
user310291 Avatar asked Jun 02 '11 19:06

user310291


People also ask

How to copy an image to paste in HTML?

3. Copy and paste your image URL into an IMG tag, add a SRC to it. Identify first where you'd like to place your image within the HTML and insert the image tag, <img>. Then take your uploaded image, copy the URL and place it within your img parameters prefaced by a src.

How do you paste an image into clipboard?

If you've put an image in the clipboard by using Ctrl+c or by right-clicking and choosing Copy or Cut, then you paste that image by using Ctrl+v or Paste in whatever location you want the copy to go.


2 Answers

Yes, HTML5 has this capability and it is becoming widely implemented. You can handle events from Ctrl+V and get binary image data and do whatever you want with it.

Currently Google Chrome 13.0.782.220 works great. I have a jQuery plugin with a full demo illustrating the feature (be sure to use Google Chrome, I can't guarantee it other browsers)

http://strd6.com/2011/09/html5-javascript-pasting-image-data-in-chrome/

As robertc mentions the Clipboard API spec is becoming standardized, so it should lead to adoption across browser soon enough.

like image 151
Daniel X Moore Avatar answered Oct 11 '22 02:10

Daniel X Moore


There is a 'Clipboard API and events' spec going through the standards process, but even if it gets implemented it's likely a user would have to explicitly enable it on a per-site basis. For example Firefox already has methods for accessing clipboard data with JavaScript, but they are turned off by default.

like image 45
robertc Avatar answered Oct 11 '22 01:10

robertc