Drag Images from external source to firefox
Moderator: General Moderators
Drag Images from external source to firefox
I am looking for a solution to dragging images from anywhere - the internet, explorer, nautilus, whatever - into a <div> on my web page - at which point the image is uploaded.
Firefox extension would be the last resort - but the ones i have seen are simply for flickr or a service like that.
Thanks
Firefox extension would be the last resort - but the ones i have seen are simply for flickr or a service like that.
Thanks
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
- aaronhall
- DevNet Resident
- Posts: 1040
- Joined: Tue Aug 13, 2002 5:10 pm
- Location: Back in Phoenix, missing the microbrews
- Contact:
Here's what I found: http://www.mozilla.org/projects/securit ... ripts.html -- never knew about it till now.
feyd | Please use [/syntax]
line 162 is the line with the var droppedFiled....
Anyone have a nice pretty fix for this before i go bald?
Thanks all
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
pulling hair out of head
[syntax="javascript"]
function dragDropHandler ( evt ) {
evt.stopPropagation();
try {
netscape.security.PrivilegeManager.enablePrivilege( 'UniversalXPConnect' );
netscape.security.PrivilegeManager.enablePrivilege( 'UniversalFileRead' );
netscape.security.PrivilegeManager.enablePrivilege( 'UniversalFileWrite' );
var dragService = Components.classes["@mozilla.org/widget/dragservice;1"].getService(Components.interfaces.nsIDragService);
var dragSession = dragService.getCurrentSession();
var transferObject = Components.classes["@mozilla.org/widget/transferable;1"].createInstance();
transferObject = transferObject.QueryInterface( Components.interfaces.nsITransferable );
transferObject.addDataFlavor("image/png");
transferObject.addDataFlavor("image/jpg");
transferObject.addDataFlavor("image/gif");
transferObject.addDataFlavor("text/plain");
for ( var i = 0; i < dragSession.numDropItems; i++) {
dragSession.getData( transferObject, i );
var dataObj = new Object();
var dropSizeObj = new Object();
var bestFlavor = new Object();
transferObject.getAnyTransferData( bestFlavor, dataObj, dropSizeObj );
alert( bestFlavor.value );
var droppedFile = dataObj.value.QueryInterface( Components.interfaces.nsIFile );
alert("dataObj filename is " + droppedFile.path + ", num is " + dropSizeObj.value);
}
} catch ( err ) { $('ad').innerHTML = err; }
}
window.addEventListener( "dragdrop", dragDropHandler, true );
Code: Select all
[Exception... "Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsISupports.QueryInterface]" nsresult: "0x80004002 (NS_NOINTERFACE)" location: "JS frame :: http://127.0.0.1:8000/jsi/Edit_Advertisement.js :: dragDropHandler :: line 162" data: no]Anyone have a nice pretty fix for this before i go bald?
Thanks all
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]From the tutorial I mentioned:
files accessed via http even if they are at 127.0.0.1 are not considered to be on the local machine's file system.A couple of things about the Mozilla permissions system need to be pointed out right now, as they will affect how this drag and drop example is built:
- Only a script on the local machine%u2019s file system or a signed script on a webpage can request that a privilege be enabled. If you attempt to call this method from an unsigned script, it will throw an exception. This does not matter for Part 1, but is the reason for Part 2 of this discussion
- An enablePrivilege request has the same scope as a variable %u2013 if you are inside a method and request enablePrivilege, that privilege will go away when the method%u2019s execution ends. Also, requesting the permission in a <SCRIPT> block on page startup will *not* grant that permission for the whole page %u2013 it will go away with the </SCRIPT> tag that ends the block
saw that, but if you change the field in about:config
shouldn't it act like it was a signed script?
Code: Select all
user_pref("signed.applets.codebase_principal_support", true);Okay, so I have it working when the signed.applets.codebase_principal_support value is set to true. But now, I would need to set this value to true on the computers that access this page. Is it possible to have firefox ask the user whether the preference should be changed when I execute a command?
The page will be used for internal company purposes, so we can instruct the workers to allow this preference to be changed.
The page will be used for internal company purposes, so we can instruct the workers to allow this preference to be changed.