Skip to main content
Participant
December 19, 2017
Question

Using File.openDialog with javascript

  • December 19, 2017
  • 3 replies
  • 2737 views

Hi,

i want to give users the chance to open things like powerpoint or videos directly by clicking a button in my pogramm.

I know that i can use something like this

function open_File()

{

window.open("myshow.pptx","","height=400,width=400,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,left=0,top=0");

}

but how can i manage to let the user choose a file from his pc? I thought of using File.openDialog, safe the file path as an variable and open it. But right now i didnt manage to work with File.openDialog. Hoping for some advices.....

The Powerpoints and so on don't need to start in animate,

Greetings

Frank

This topic has been closed for replies.

3 replies

Participant
December 22, 2017

Thanks for the link.

I solved the problem on another way ..

var file = document.getElementById("File");

file.type = "file";

this.btn_File.addEventListener("click", getFile.bind(this));

function getFile()

{

file.click();

var Filepath = file.value;

var Filname = Filepath.substr(Filepath.lastIndexOf('\\')+1,Filepath.lastIndexOf('.')+1);

if (Filname != 0)

{window.open("ppt/"+Filname,"","height=400,width=400,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,left=0,top=0");

}

}

i get the path, extrude the filename and open it with a programm used by the pc.

Next step will be to make an own input file component, so i can use it right from the start without the type change.

I know that the file must be in a special folder, buts thats totally ok for my purpose.

Legend
December 22, 2017

Why would someone use a web page to open files on their own computer? What's the use case here?

Legend
December 19, 2017

So, once you get the path to the file on the user's local drive... what exactly do you intend to do with it?

kglad
Community Expert
Community Expert
December 19, 2017