Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. [WASM] Get full file path name from QFileDialog::getOpenFileContent
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
webassemblyfile dialogemscripten
2 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mixlu
    wrote on 23 Jun 2020, 07:05 last edited by Mixlu
    #1

    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.

    1 Reply Last reply
    1
    • J Offline
      J Offline
      Juangpc
      wrote on 2 Jul 2020, 17:17 last edited by
      #2

      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 )

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved