Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "J.O. Aho" <user@example.net> |
| Newsgroups | alt.php |
| Subject | Re: Get root directory in archive |
| Date | Fri, 2 Jul 2021 09:07:10 +0200 |
| Lines | 29 |
| Message-ID | <ik7s8uFpbqdU1@mid.individual.net> (permalink) |
| References | <iL6dnfbxRIzl60P9nZ2dnUU7-N3NnZ2d@westnet.com.au> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net DedJL0U2+Yuh/wQzAelVPQH+Z7PFZy5QdHJYIRqucKXKW/Uz4J |
| Cancel-Lock | sha1:SR07g/ZqDS7D+QAzoFmVimA3ykw= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
| In-Reply-To | <iL6dnfbxRIzl60P9nZ2dnUU7-N3NnZ2d@westnet.com.au> |
| Content-Language | en-US-large |
| Xref | csiph.com alt.php:3274 |
Show key headers only | View raw
On 02/07/2021 04.14, Andrew Poulos wrote: > Users can upload a archive (zip) to the server. On the server I can use > extractTo to extract the archive's contents. > > The problem I have is that users should create an archive of an entire > directory and not just the directory's contents (so that when the > archive is extracted the contents will be in a directory.) > > How can I test whether all the files, and any sub-directories within an > archive, are within one directory? You will need to use the getNameIndex to list the files https://www.php.net/manual/en/ziparchive.getnameindex.php > If they are within one directory I would also like the directory's name. you would use dirname to figure out the path, you can use the level to get the root. https://www.php.net/manual/en/function.dirname.php You can store the first files root directory in a variable, then check if the next file has the same root as the previous one, if they differ, than you know there is multiple directories. If the variable value is empty, then you have files directly in the root. -- //Aho
Back to alt.php | Previous | Next — Previous in thread | Next in thread | Find similar
Get root directory in archive Andrew Poulos <ap_prog@hotmail.com> - 2021-07-02 12:14 +1000
Re: Get root directory in archive "J.O. Aho" <user@example.net> - 2021-07-02 09:07 +0200
Re: Get root directory in archive Andrew Poulos <ap_prog@hotmail.com> - 2021-07-03 15:58 +1000
csiph-web