开发者

How do I let a user paste an image on a webpage?

开发者 https://www.devze.com 2022-12-29 11:45 出处:网络
I want to give the user possibility to paste an image into a webform. I don\'t need to display the image, all I need is the image\'s location.

I want to give the user possibility to paste an image into a webform. I don't need to display the image, all I need is the image's location.

I know it's possible because the guys at CKEditor(and other editors) are doing it.

If you go here, http://ckeditor.com/demo and paste an image you copied and then right click on it and go to image properties you'll see they have the image's address.

How can this be do开发者_Go百科ne?

Thanks


It is not possible because giving a browser the possibility to access local files, which have not been added to be uploaded explicitly by the user, opens a variety of very dangerous security holes that would certainly be super-exploited by hackers.

A good solution would be to give the posibility to upload using Ajax and link the images in the document once they are available in the server.

Take a look at “Sending files using a FormData object” part of the Using XMLHttpRequest document at Mozilla Developer Network.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号