我在拖放區域設置了一個ondrop事件,當我從桌面拖動圖像到拖放區域時,它會收到一個事件。我可以將文件從桌面拖到Firefox 3.5中的拖放區域並啓動上傳嗎?
然而,根據Recommended_Drag_Types文件:
https://developer.mozilla.org/en/DragDrop/Recommended_Drag_Types
A local file is dragged using the application/x-moz-file type with a data value that is an nsIFile object. Non-privileged web pages are not able to retrieve or modify data of this type.
這是有道理的,但我怎麼提示用戶提升權限以訪問文件數據,並通過發送XMLHttpRequest
?
如果我嘗試沒有升級權限,當我做這個代碼:
event.dataTransfer.mozSetDataAt("application/x-moz-file", file, 0);
的Javascript返回此錯誤:
Permission denied for domain.com to create wrapper for object of class UnnamedClass
我可以找到關於這個問題的唯一物品是從2005年,但我不知道方向仍然適用於Firefox 3,它建議這樣做:
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
其中d似乎沒有工作。
你找到了答案嗎?我希望能夠至少捕獲本地網址。有任何想法嗎? thx男人 – 2009-11-12 04:17:13
它現在可能!看到我的答案:http://stackoverflow.com/a/33431704/195216 – dforce 2015-10-30 08:40:45