Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[WASM] Get full file path name from QFileDialog::getOpenFileContent



  • Hi,
    I would like to get the full file path name of a file with QFileDialog::getOpenFileContent but I only get the file name. Here is my code :

    auto fileContentReady = [](const QString &fileName, const QByteArray &fileContent) {
            if (fileName.isEmpty()) {
                // No file was selected
                qDebug() << fileName << endl;
            } else {
                // Use fileName and fileContent
                qDebug() << fileName << endl;
           }
           QFileInfo fi(fileName);
           qDebug() << "path: " << fi.path() << endl;
            
        };
        QFileDialog::getOpenFileContent("Images (*.png *.xpm *.jpg)",  fileContentReady);
    

    in webassembly, both fileName and fi.path() return the file name, not including the full path.
    I am using Qt 5.13.2 with emscripten 1.38.30.



  • Short answer... you can't get the full file path of a file.

    Your question is more related to safety/security standards regarding major browsers and the decisions related to them made by owner companies/foundations.

    That is, javascript is not allowed to know the full path of a file shared by the user. So, fileContentReady or in general any webassembly function will end up being a javascript function, limited to the security standards imposed on js implementation by the browser.

    (You can always ask the user to install a java applet :P )



  • Short answer... you can't get the full file path of a file.

    Your question is more related to safety/security standards regarding major browsers and the decisions related to them made by owner companies/foundations.

    That is, javascript is not allowed to know the full path of a file shared by the user. So, fileContentReady or in general any webassembly function will end up being a javascript function, limited to the security standards imposed on js implementation by the browser.

    (You can always ask the user to install a java applet :P )