For a custom WordPress plugin, I'm trying to allow my users to select a folder and use it as the file download path. Example: If the user selects the folder "C://Users/Kahiego/Desktop/img", may it be empty or not, when they'll try to download files from the plugin, everything will get downloaded in there.
So far all I can achieve right now is allowing to select a folder:
<form action="" method="post" enctype="multipart/form-data">
<input type="file" id="ctrl" webkitdirectory directory multiple/>
<input type="submit" value="Upload Image">
</form>
(but it will only count as a multiple file select). I checked on various posts already but none can tell me how to achieve this (with some saying they don't see how this could be useful).
Any idea?
Thanks in advance.
Edit: What I mean by this: I want the admin to be able to pick a folder. I just want to retrieve the path, and use it somewhere else; not necessarily right afterward.
After retrieving the uploaded file, I currently use:
move_uploaded_file($_FILES["file"]["tmp_name"], "../../../img/" . $_FILES["file"]["name"]);
to store the files. I just wanted to allow to store the path in a variable through an input and use it afterwards in this case.
I'm not talking about browsing user's folders, but allowing the server to pick the location where files are downloaded, on the server itself, without writing the path, just by letting the admin selecting it by browsing files.
The flagged duplicated post does not answer or not totally answer what I'm looking for, since it's either selecting a folder - with every files in there - or not allowing to select a folder which is empty. Would be perfect to reproduce the functionality of those "select a directory" functions when you first install a software.
I hope I clarified enough, I'm really bad at explaining things.