How do I open browser dialog to load without NW.JS/FileChoos

0 favourites
  • 2 posts
From the Asset Store
This is a single chapter from the Construct Starter Kit Collection and the Student Workbook from the Workshop.
  • How can i open the browser dialog to load an image without use the NW.JS plugin or the "File Chooser" plugin wich is a form control ?.

    I tried to look in the browser actions but only appears "invoke download" to open the browse dialog to save some file but can't find the one for load to be used in the online version without form controls ¿?.

    Maybe i guess i should use "execute javascript" but can't find any code to do that. Any idea?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Well seems i have a solution. Provided by dop2000 .

    Loading a .txt with ajax plugin with this content:

    var global = Function('return this')(); //get global scope.
    global.openFileDialog = function(fileType) { 
     // this function must be called from  a user
     // activation event (ie an onclick event)
        // Create an input element
        var inputElement = document.createElement("input");
        // Set its type to file
        inputElement.type = "file";
        // Set accept to the file types you want the user to select. 
        // Include both the file extension and the mime type
        inputElement.accept = fileType;
        // set onchange event to call callback when user has selected file
        inputElement.addEventListener("change", function (event) {
        [...this.files].forEach(file => {
            //var s =;
    var url = URL.createObjectURL(file);
            c2_callFunction("GetFileFromDialog", [url]);
         } );
        // dispatch a click event to open the file dialog
        inputElement.dispatchEvent(new MouseEvent("click")); 
    An execute javascript with "openFileDialog();" on sprite clicked or whatever.
    Is a bit of workaround but seems works on any browsers and NW.JS. 
    If somebody know another solution/way, let me know.
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)