Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

allow image preview before upload

  • 28-09-2010 01:33PM
    #1
    Registered Users, Registered Users 2 Posts: 64 ✭✭


    Has anyone tried this? It's a requirement for a web app. (asp.net 3.5). Is javascript my best/only option? I won't be happy with an IE specific solution. Any ideas?


Comments

  • Registered Users, Registered Users 2 Posts: 431 ✭✭plenderj


    I think you'll need to use an ActiveX control (or a Java applet? or silverlight?), and the user would probably get a security warning, to be allowed to load a file directly off the drive


  • Registered Users, Registered Users 2 Posts: 64 ✭✭Ginkgo


    I found this solution that works in Internet explorer (tested in IE 8). I haven't found a solution that works for all browsers which is what I would obviously prefer. I had to add site to trusted sites list for this to work.

    http://forums.asp.net/p/1437099/3249950.aspx

    Any other ideas are welcome.


  • Registered Users, Registered Users 2 Posts: 218 ✭✭Tillotson


    HTML5 has a ondrop event.
       function urlDropped(url) {
            var img = document.createElement('img');
            img.onload = function(e) {
                    document.body.appendChild(this);
            }
            img.src = url;
        }
    
        function drop(tgt, e) {
            var dt = e.dataTransfer;
            var file = dt.files[0];
            var reader = new FileReader();
            reader.onload = function(e) {
                urlDropped(e.target.result);
            };
        }
    ...
    <body ondrop="drop(this, event)" ondragover="return false">
    
    Cross browser? All I can say is that it works for me in Chrome


Advertisement