0

I am getting image from clipboard and putting in img tag.

So when user click on a button, image from the clipboard is copied into img tag in one div tag. So I have list of img tags within one div.

I want to save that images on server, So I have to send that images to server side.

How can I send that images on server side ?

Please guide. Thanks.

=== Code Sample ===

<div id="imageContainer">
       <img src="..."/>
       <img src="..."/>
       <img src="..."/>
</div>

this is the structure and want to upload this images on server.

Gaurang
  • 65
  • 2
  • 12
  • You cannot upload images with JS since JS cannot interact with your file system. – Nemanja Jul 05 '12 at 09:00
  • I have images in img tag already. Just want to send them to Server. Thank you. – Gaurang Jul 05 '12 at 09:02
  • Possible duplication of http://stackoverflow.com/questions/490908/paste-an-image-from-clipboard-using-java-script – flec Jul 05 '12 at 09:02
  • wait..you want to upload images or update your db with image path ? – coolguy Jul 05 '12 at 09:03
  • 1
    @Nemanja You're a little off-topic, OP is not trying to invade your comp. [Check the HTML5 File API.](http://html5demos.com/file-api/) And what OP is looking for is the XMLHttpRequest Level 2 to send files over Ajax. – Fabrício Matté Jul 05 '12 at 09:04
  • @FabrícioMatté : Exactly..want to send that images through Ajax or normal request. – Gaurang Jul 05 '12 at 09:07
  • @flec Getting image from clipboard is not issue here..that's different question. – Gaurang Jul 05 '12 at 09:09
  • @ubercooluk Yes I want to upload images which are in img tags, multiple images – Gaurang Jul 05 '12 at 09:09
  • The problem is, [XHR2 is not compatible with IE<=9](http://caniuse.com/xhr2), so if you want cross-browser compatibility you'll probably need a fallback, which will be really hard to code if you don't show any code samples. – Fabrício Matté Jul 05 '12 at 09:11
  • @FabrícioMatté would it work in other browsers ? – Gaurang Jul 05 '12 at 09:13
  • Of course. The link I posted shows the full compatibility table. `:)` – Fabrício Matté Jul 05 '12 at 09:16
  • @FabrícioMatté Thank you.. but how can I do so ? Can you please provide code snippet ? – Gaurang Jul 05 '12 at 09:21
  • 1
    It's hard if you don't show exactly what you're trying to do.. For instance, you have ` – Fabrício Matté Jul 05 '12 at 09:24
  • There is one button "Add Screenshot", on click of that button new img tag would be created with the image in clipboard. so one by one user can add multiple img tags. At last clicking on "Submit" button all images will get uploaded to server. – Gaurang Jul 05 '12 at 09:27
  • 1
    That's making progress. You can edit the question to include the new info, now if you could add some example markup from your page's generated html with the screenshots it'd be a breeze to make a [jsfiddle](http://jsfiddle.net) and you'd have an answer almost instantly. – Fabrício Matté Jul 05 '12 at 09:29
  • Also, if you plan to do the PHP from the ground, there are **many** issues which you may run into if you're making this for the open public. If you're going to store the files in a folder on your server, you have to take precaution against malware, PHP/SQL injection, XSS etc. I'd use [BlueImp File Upload](http://blueimp.github.com/jQuery-File-Upload/), [Plupload](http://www.plupload.com/) or [Uploadify](http://www.uploadify.com/) - not sure which of these have support for clipboard handling and you'll have to adapt your page a little, but that's still less work than making the php from ground. – Fabrício Matté Jul 05 '12 at 09:52
  • @FabrícioMatté Thank you friend, for the mark up I have included in the description. If you are comfortable please give your skype – Gaurang Jul 05 '12 at 10:53
  • Yeah I can help, but couldn't you put a little more effort in solving your issue here? Such as which API you're using to handle the images inserting, a possible [SSCCE](http://sscce.org) in [JSFiddle](http://jsfiddle.net) or a link to the page it's being used on. There are many people here that will help if you provide details, and questions are automatically bumped to the top of the newest questions list when you edit your question, so do so including more info. – Fabrício Matté Jul 05 '12 at 19:01

0 Answers0