0

I want to use php to copy an image to my server which is easy. But is there a way to get the url that I would be copying from using Jquery drag and drop so that the user can simply drop an image in a box and then submit a form.

Thanks Ian

Olokoo
  • 1,114
  • 3
  • 19
  • 34
  • 1
    Can you clarify "the url that I would be copying from" ? Are you talking about the user uploading a file from their computer, or the user dropping an image that's already on the internet? – John Stimac Apr 03 '12 at 02:59
  • Sorry, I meant dragging it from an image that is already on the internet. Such as Google images – Olokoo Apr 03 '12 at 03:07
  • here is a post discussing about drag and drop http://stackoverflow.com/questions/2657653/drag-and-drop-file-upload-in-google-chrome-chromium-and-safari – Sandeep Manne Apr 03 '12 at 06:28
  • I am not trying to create a drag and drop upload, I just want to be able to get the url (http://somesite.com/image.jpg). And then put that in a text field – Olokoo Apr 04 '12 at 02:34
  • 1
    try this one http://stackoverflow.com/questions/11214053/drag-and-drop-images-from-another-website-to-mine – iPadDeveloper2011 May 14 '13 at 04:47
  • Correct, I ended up using something exactly like that! – Olokoo May 29 '13 at 01:58

1 Answers1

1

Try This

var data = $(event.dataTransfer.getData('text/html'));
var src = event.dataTransfer.getData("Text");


var img = data.attr('src'); // if link then it is showing undefined
if (!img) {      // if link then we are getting it from linked img source
  var img = data.find("img").attr('src');