Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer Tip: Drag & Drop Files into I.E. (JScript/OLE)

    Something I've wanted to figure out for a while... perhaps you have too.

    The Windows common controls include a VBDataObject interface that can be utilized during drag|drop events (as an argument).
    Retrieving the path of files dropped onto a control is as simple as checking the format of the Data Object for vbCFFIles (constant = 15), and if true, enumerating the Files collection (1-based) for each item (which returns the full path as a string).

    The Animation Control is simplest one I've found for demonstrating this:
    Some information about that control is here...

    Code:
    <html>
    <head>
    <title>IVBDataObject Demo</title>
    
    <style type="text/css">
    fieldset{
    text-align:center;
    padding:2em
    }
    object{
    width:3em;height:3em;
    border:6px double activecaption;
    vertical-align:middle
    }
    textarea{
    width:60%;margin-top:1em;
    word-wrap:normal;
    vertical-align:middle
    }
    </style>
    
    </head>
    <body>
    
    <fieldset>
    <legend><strong>Drop File(s)  </strong>
    
    <object id="IAnimation" 
    classid="clsid:B09DE715-87C1-11D1-8BE3-0000F8754DA1">
    <param name="OleDropMode" value="1">
    </object>
    
    &nbsp;</legend>
    <label><em>output: </em></label>
    <textarea id="output" cols="100" rows="10"></textarea>
    </fieldset>
    
    
    <script type="text/JScript">
    
    function IAnimation::OLEDragDrop(Data){
    if(Data.GetFormat(15)){
    var O = "";
    var e = new Enumerator(Data.Files);
    while(!e.atEnd()){
    O += e.item() + "\n";
    e.moveNext();
    }
    output.value = O;
    BackColor=0x80000003;}
    }
    
    
    // Just for visual feedback...
    
    function IAnimation::OLEDragOver(Data, _, _, _, _, _, State){
    if (State == 0){
    if(Data.GetFormat(15)){Backcolor = 0x80000002;}
    }
    if(State == 1){Backcolor = 0x80000003;}
    }
    
    function window::onload(){
    IAnimation.BackColor=0x80000003;
    }
    </script>
    </body>
    </html>
    Probably most useful in HTAs, when scripting the FileSystem or Shell objects...
    hmm... ?

  • #2
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question What happens to the file you dragged?

    This works as I expect when I left-click drag a file from most folders. The full paths of the dragged files show up in the text box but the files remain unchanged.

    When I drag files from D:\Documents and Settings\Paul\Local Settings\Temporary Internet Files, the full paths still show up, but the files are DELETED. View refresh does not see them.

    Is this expected behavior? I certainly didn't expect it.

    My system is WXP SP1 1Gb memory, 1700Mhz Celeron. AOL's McAffee viruscan updates and runs daily, with no reported problems.

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Special Folder

    It works when dragging files from that folder's "Content.IE5" subdirectory (where the data is stored). It fails from "Temporary Internet Files" because these just point into the cache (Content.IE5). The Windows Shell can handle the temp files, so you can either drag them into the filesystem first, or search the underlying cache for the actual files and drag those onto the control.
    Thanks in advance!

  • #4
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Are other 'special folders' similarly affected?

    Thanks for the quick reply. I needed to know that it wasn't a problem unique to my computer. Do you think any other 'special folders' are similarly affected?

  • #5
    Regular Coder
    Join Date
    May 2005
    Posts
    313
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Are other 'special folders' similarly affected?

    maybe...
    Last edited by enumerator; 06-23-2005 at 11:01 PM. Reason: ^
    Thanks in advance!

  • #6
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How can I save the file to my server. I tried using Data.GetData() but I'm not sure what kind of type I have to pass in as a parameter. The files being dragged on are image files.

  • #7
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    TO swmr: Yes you are right i have been wanting ti figure that our too and I thank you for this very informative and very educational post you have done, I am looking forward to see more of your informative sites.

  • #8
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have book marked this page for the future purposes. I have some queries about the topic but I'll just email this to the writer because I want it to be personal.. Thanks for the post until next time.

  • #9
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found this link on the net after I read the file I tried everything that you have shared.. this is the link and I hope that it will help you on your project **http://www.webreference.com/programm.../mk/column2/**. This is a video tutorial about the Drag and Drop of Javascript.. i am new in the field that is why I am not sure if this will help you.

  • #10
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by edgars apalais View Post
    I found this link on the net after I read the file I tried everything that you have shared.. this is the link and I hope that it will help you on your project **http://www.webreference.com/programm.../mk/column2/**. This is a video tutorial about the Drag and Drop of Javascript.. i am new in the field that is why I am not sure if this will help you.
    Hmm, I've tried to check the video tutorial that you were actually referring too, but no offense, but it seems to be a bit vague for the subject. But still, thanks for your effort edgar

  • #11
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I agree with what you have said and I thank you for sharing this very innovative and insightful information.. but I still have questions about your post, can I just send an email for my questions.

  • #12
    New to the CF scene
    Join Date
    Jun 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Do you mind if the copy the script and edit it a bit? I'd like to try a few workarounds and keep you updated about what would actually happen..

  • #13
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    smr for some reason the code I copied did not implement well in my site.
    Any feedback?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •