13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using Directory Functions<br />

439<br />

some directory that you have access to.You might also need to adjust the memory_limit<br />

directive if you want to upload large files; this determines the maximum<br />

file size in bytes that you can upload. Apache also has some configurable timeouts<br />

<strong>and</strong> transaction size limits that might need attention if you are having difficulties<br />

with large uploads.<br />

Using Directory Functions<br />

After the users have uploaded some files, it will be useful for them to be able to see<br />

what’s been uploaded <strong>and</strong> manipulate the content files. <strong>PHP</strong> has a set of directory <strong>and</strong><br />

file system functions that are useful for this purpose.<br />

Reading from Directories<br />

First, let’s implement a script to allow directory browsing of the uploaded content.<br />

Browsing directories is actually straightforward in <strong>PHP</strong>. Listing 19.3 shows a simple script<br />

that can be used for this purpose.<br />

Listing 19.3<br />

browsedir.php—A Directory Listing of the Uploaded Files<br />

<br />

<br />

Browse Directories<br />

<br />

<br />

Browsing<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!