Closed Mic-B closed 12 hours ago
I'll see if I can replicate this issue with the ini settings as that definitely doesn't seem right.
But assuming the files are on the same system where the app is running, why not simply get the path to the file and read its contents directly in PHP? Do you need to "upload" it?
Using the native file dialog you can get the user to select the file and then pass the path to fopen
/file_get_contents
/Laravel's File::open()
Hi @simonhamp, thank you for your reply!
I am using the native file dialog as a workaround at the moment actually, but I would much prefer to allow users to drag and drop into my application. It is far more user friendly (at least for my use case) and most mac users will expect that type of interaction from a native application. The limits from the default php.ini are the only thing stopping me from going that route currently.
Please let me know if there are any additional things to try or if you need any other information!
Cheers
I understand. I agree, that interaction/UX can be much nicer.
I guess drag-and-drop doesn't get you the full path... ? From my research this seems to be an intentional limitation of the FileSystemFileHandle
API, though I haven't dug too far.
I found that Microsoft implemented another approach for WebView2 - which is based on Chromium afaik - but I can't find anything about Chromium adopting this API or something similar yet, so I expect Electron doesn't have anything like this yet.
Aside: Not sure if you're aware, but on macOS it's possible to drag and drop onto the file chooser dialog. This has the effect of jumping the CWD in the dialog to the location of the dropped file.
Classic, I just post an answer and then find something
It looks like we'd be able to do something with this to get the full path to a dropped file and inform your Laravel application that the drop occurred and what the absolute path was.
That could be the longer-term solution. I will ponder this some more.
Thanks again for your replies @simonhamp!
I understand that you can't get the full path from drag and drop, but that's not necessary when I can post the binary data directly. The only thing stopping me is php.ini not reflecting my updated values.
Hope you have a good one! Cheers.
Yep I agree. That's probably overall the simpler solution. Going to leave this open whilst I investigate that specifically
@Mic-B
I have tested this in the versions you where using and came to the same conclusion as you did, that the values do not update.
What my suggestion would be is to upgrade to the newest version, that did the trick for me.
@simonhamp Thank you so much for your efforts! I really appreciate it.
@JCombee Oh I didn't realize I was behind. I'll update and report back!
@JCombee That did the trick! After upgrading to nativephp/electron v0.8.5 the php ini settings are now working.
@simonhamp My apologies for wasting your time on this, after an upgrade it is working great.
Hope you both have a good one!
No apology needed! Sorry I didn't spot that you were running an older version.
Glad this sorted it! Thanks @JCombee for looking through one with a sharper pair of eyes than me.
What were you trying to do?
I am currently trying to upload large binary files to my application. All of my requests return with
POST Content-Length of [XXX] bytes exceeds the limit of 8388608 bytes
. To remedy this, I have attempted to update the php.ini directives using thephpIni()
function inNativeAppServiceProvider
.What happened?
I expected the variables to update to the values as passed. However when outputting these variables in a page from within my application, the values are still set to the defaults. This does not change whether I am using
php artisan native:serve
or if I build the application, install it, and run it standalone.How to reproduce the bug
Start with a fresh installation of Laravel and NativePHP, then attempt to change phpIni() variables and check their values from within your application code.
Package Versions
{ "installed": [ { "name": "nativephp/electron", "direct-dependency": true, "homepage": "https://github.com/nativephp/electron", "source": "https://github.com/NativePHP/electron/tree/0.4.0", "version": "0.4.0", "description": "Electron wrapper for the NativePHP framework.", "abandoned": false }, { "name": "nativephp/laravel", "direct-dependency": false, "homepage": "https://github.com/nativephp/laravel", "source": "https://github.com/NativePHP/laravel/tree/0.4.0", "version": "0.4.0", "description": "Laravel wrapper for the NativePHP framework.", "abandoned": false }, { "name": "nativephp/php-bin", "direct-dependency": false, "homepage": "https://nativephp.com", "source": "https://github.com/NativePHP/php-bin/tree/0.3.0", "version": "0.3.0", "description": "PHP binaries used by the NativePHP framework", "abandoned": false } ] }
PHP Version
8.1.17
Laravel Version
10.10
Node Version
18.20.3
Which operating systems have you seen this occur on?
macOS
OS version
macos13.6.7
Notes
Thank you so much for all that you do! Been loving working with NativePHP so far. Cheers!