1

So for example take a site like Imgur which has a drag and drop feature for uploading images. If I drag three files from a folder on my desktop and drop them into there, it will know the order in which they were highlighted before I dragged and dropped them, regardless of filename or arrangement in the directory. How does it know this? I'm assuming they are using Javascript.

Lucifer N.
  • 966
  • 3
  • 15
  • 34
  • At Imgur files order is not the same as on the disk (Windows 8.1, Chrome). As I see sometimes matters even what file from files selection you clicked when dragging – Ihar Krasnik Jul 01 '14 at 14:50

1 Answers1

0

I'm not sure that you can make an assumption that it does know the order. The order is set by whatever the OLE client sends when creating data from the drag-request. The client you mention (client running in browser that accepts the drop of files) probably has its own means of doing the sort, either by file name, or by date, and would most likely update upon the download of each successive file.

Most file drag-drop operations (in Windows) initiate from Windows Explorer, but there's no reason why a custom application couldn't populate data for such a request, and set the order of files for the drag-drop in any order.

A starting point for OLE drag/drop (in Windows): http://msdn.microsoft.com/en-us/library/s7s7td0c.aspx

CJBS
  • 15,147
  • 6
  • 86
  • 135
  • I'm using Linux and its working for me. I was asking about this because I'm trying to implement a similar functionality, and if multiple files are dropped I want them to be displayed on a webpage in the order they were dropped in. The JS library I'm using already knows the order, but I didn't know HOW it knew this and couldn't figure out from the code. Serving them is a different story as I'm doing it with Python(the upload time is stored in a db), and couldn't figure a way to know the order. I could just sort by time, but what about something like parallel uploads which I might want to have? – Lucifer N. Feb 27 '14 at 09:09
  • I would imagine that it's just a collection of objects that is enumerated. Have a look at this, for example: http://stackoverflow.com/a/12633836/3063884 – CJBS Feb 27 '14 at 09:11