javascript - Choose file window in extension firefox -


iam building extension , want take path of file window popup windows . use in extension in firefox?

enter image description here

you should check out this page on mdn

creating file picker

to begin, need create file picker component , initialize it.

var nsifilepicker = components.interfaces.nsifilepicker; var fp = components.classes["@mozilla.org/filepicker;1"].createinstance(nsifilepicker); fp.init(window, "select file", nsifilepicker.modeopen); 

first, new file picker object created , stored in variable 'fp'. 'init' function used initialize file picker. function takes 3 arguments, window opening dialog, title of dialog , mode. mode here modeopen used open dialog. can use modegetfolder , modesave other 2 modes. these modes constants of nsifilepicker interface.

getting selected file

finally, can show dialog calling show() function. takes no arguments returns status code indicates user selected. note function not return until user has selected file. function returns 1 of 3 constants:

returnok - user selected file , pressed ok. file user selected stored in file picker's file property.

returncancel - user pressed cancel.

returnreplace - in save mode, return value identifies user selected file replaced. (returnok returned when user entered name of new file.) should check return value , file object file picker using file property.

var res = fp.show(); if (res != nsifilepicker.returncancel){   var thefile = fp.file;   // --- file here --- } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -