diff --git a/resources/views/docs/desktop/2/digging-deeper/files.md b/resources/views/docs/desktop/2/digging-deeper/files.md index 198782783..4a5e6d934 100644 --- a/resources/views/docs/desktop/2/digging-deeper/files.md +++ b/resources/views/docs/desktop/2/digging-deeper/files.md @@ -95,6 +95,40 @@ 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 + +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: + +```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.