From f84b5f459e065fd439f115cb660741704a8ee919 Mon Sep 17 00:00:00 2001 From: David Alberts Date: Wed, 4 Nov 2026 14:47:23 -0700 Subject: [PATCH 1/2] Document window.Native.getPathForFile for dropped files NativePHP/desktop#170 added getPathForFile to window.Native because Electron 32 removed File.path. Explain how to use it, what it returns when there's no file on disk, and how to stop stray drops navigating the window. --- .../docs/desktop/2/digging-deeper/files.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/resources/views/docs/desktop/2/digging-deeper/files.md b/resources/views/docs/desktop/2/digging-deeper/files.md index 198782783..e25f2cece 100644 --- a/resources/views/docs/desktop/2/digging-deeper/files.md +++ b/resources/views/docs/desktop/2/digging-deeper/files.md @@ -95,6 +95,39 @@ We recommend avoiding symlinks within your NativePHP app. Instead, consider eith - Placing files directly in their intended locations - Using Laravel's Storage facade to mount directories outside your application +### Getting the path of a dropped file + +For security, the browser doesn't tell your page where a dragged-in file lives on disk. NativePHP exposes Electron's +[`webUtils.getPathForFile()`](https://www.electronjs.org/docs/latest/api/web-utils) as `window.Native.getPathForFile()`, +which returns the full path of a `File` from a drop or a file input. + +This example passes the path to a `useFile` method on a Livewire component: + +```blade +
+ Drop a file here +
+``` + +It returns an empty string when the `File` isn't backed by a file on disk, for example one created in JavaScript, so check +for that before using it. Something dragged from a web browser depends on the browser: it can come back as the path of a +temporary copy the browser made, or the drop may contain no files at all. + + + ## Bundling Application Resources NativePHP allows you to bundle additional files with your application that can be accessed at runtime. This is useful for including pre-compiled executables or other resources that need to be distributed with your app. From 38466f7c28fac236ff41c479c893ca190925dc70 Mon Sep 17 00:00:00 2001 From: David Alberts Date: Wed, 4 Nov 2026 15:03:04 -0700 Subject: [PATCH 2/2] Use the docs' own terms in the getPathForFile intro The docs use 'the browser' for the user's web browser, and the next paragraph of this section does too, so describe JavaScript running in a window instead. --- resources/views/docs/desktop/2/digging-deeper/files.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/views/docs/desktop/2/digging-deeper/files.md b/resources/views/docs/desktop/2/digging-deeper/files.md index e25f2cece..4a5e6d934 100644 --- a/resources/views/docs/desktop/2/digging-deeper/files.md +++ b/resources/views/docs/desktop/2/digging-deeper/files.md @@ -97,9 +97,10 @@ We recommend avoiding symlinks within your NativePHP app. Instead, consider eith ### Getting the path of a dropped file -For security, the browser doesn't tell your page where a dragged-in file lives on disk. NativePHP exposes Electron's -[`webUtils.getPathForFile()`](https://www.electronjs.org/docs/latest/api/web-utils) as `window.Native.getPathForFile()`, -which returns the full path of a `File` from a drop or a file input. +JavaScript running in a window can read a dropped file's name and contents but, for security, not where it lives on +disk. To get the path, use `window.Native.getPathForFile()`, which wraps Electron's +[`webUtils.getPathForFile()`](https://www.electronjs.org/docs/latest/api/web-utils) and returns the full path of a `File` +from a drop or a file input. This example passes the path to a `useFile` method on a Livewire component: