https://github.com/terremoth/php-win32-filepicker
Use native Windows Explorer File Selector to select a file on PHP
https://github.com/terremoth/php-win32-filepicker
Last synced: 18 days ago
JSON representation
Use native Windows Explorer File Selector to select a file on PHP
- Host: GitHub
- URL: https://github.com/terremoth/php-win32-filepicker
- Owner: terremoth
- License: gpl-3.0
- Created: 2025-03-05T19:18:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-11T08:15:53.000Z (over 1 year ago)
- Last Synced: 2025-08-24T18:05:34.542Z (10 months ago)
- Language: PHP
- Size: 61.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Win32 File Picker
Calls Windows Explorer to select file(s).
You are able to configure to select 1 or multiple files,
filtering by extensions or let the user free to choose any.
Unlocked by the power of PHP's [FFI](https://www.php.net/manual/en/book.ffi.php)
_Not because we must do it, but because we can!_
Made by [Terremoth](https://github.com/terremoth/) with ⚡ & ❤
[](https://github.com/terremoth/php-win32-filepicker/actions/workflows/workflow.yml)
[](https://github.com/terremoth/php-win32-filepicker/blob/main/LICENSE)
[](https://packagist.org/packages/terremoth/php-win32-filepicker)
[](https://packagist.org/packages/terremoth/php-win32-filepicker)
[](https://discord.gg/JxFhMVWu82)
[](https://scorecard.dev/viewer/?uri=github.com/terremoth/php-win32-filepicker)
[](https://codecov.io/gh/terremoth/php-win32-filepicker)
[](https://codeclimate.com/github/terremoth/php-win32-filepicker/test_coverage)
[](https://shepherd.dev/github/terremoth/php-win32-filepicker)
[](https://shepherd.dev/github/terremoth/php-win32-filepicker)
[](https://app.codacy.com/gh/terremoth/php-win32-filepicker/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[](https://codeclimate.com/github/terremoth/php-win32-filepicker/maintainability)
## Installation
```sh
composer require terremoth/php-win32-filepicker
```
## Documentation
```php
require_once 'vendor/autoload.php';
use Terremoth\Win32\FilePicker;
$selectedDirectory = $_SERVER['USERPROFILE'] ?? 'C:\\'; // optional
$fp = new FilePicker($selectedDirectory); // $selectedDirectory can be null without problem.
// all methods below are *optional*:
$fp
->selectMultipleFiles()
->addExtensionsFilter(['png', 'jpg', 'gif', 'avif', 'webp', 'jpeg', 'ico', 'bmp'])
->filterOnlySelectedExtensions()
->setDefaultExtensionSearch('png')
;
$selectedFiles = $fp->open();
print_r($selectedFiles);
// if no files were selected, an empty array will be returned 😉
```
That's it!
See [demos/demo.php](demos/demo.php) for this example.