function FilePicker()
{
//alert("FilePicker");
var nsIFilePicker = Components.interfaces.nsIFilePicker;
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
fp.init(window, "Select a File", nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterImages | nsIFilePicker.filterAll);
var res = fp.show();
if (res==nsIFilePicker.returnOK)
{
var thefile = fp.file;
//alert("thefile:"+thefile);
alert("file path:"+thefile.path);
var filepath = thefile.path;
filepath = filepath.replace(":","|");
alert("filepath:"+filepath);
filepath = filepath.replace(/\\/g,"/");
//filepath = filepath.replace(new RegExp("\\","g"),"/");
alert("filepath:"+filepath);
var src_path= "file:///"+filepath;
alert("src_path:"+src_path);
var img = document.getElementById('show-image');
img.setAttribute("src",src_path);
}
}
留言列表