11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

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

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

CHAPTER 15 • HANDLING FILE UPLOADSwww.it-ebooks.infoThe key values and their respective properties are discussed earlier in this chapter, so there’s noreason to describe them again (besides, all the names are rather self-explanatory). If you’re interested injust retrieving the value of a single property, pass a key to the getProp() call. For example, suppose youwant to know the size (in bytes) of the file:echo $files->getProp('size');This produces the following output:22616Uploading Multiple FilesOne of the beautiful aspects of HTTP_Upload is its ability to easily manage multiple file uploads. To handlea form consisting of multiple files, all you have to do is invoke a new instance of the class and callgetFiles() for each upload control. Suppose the aforementioned professor has gone totally mad andnow demands five homework assignments daily from his students. The form might look like this:Last Name:Homework #1:Homework #2:Homework #3:Homework #4:Homework #5:Handling this with HTTP_Upload is trivial:$homework = new HTTP_Upload();$hw1 = $homework->getFiles('homework1');$hw2 = $homework->getFiles('homework2');$hw3 = $homework->getFiles('homework3');$hw4 = $homework->getFiles('homework4');$hw5 = $homework->getFiles('homework5');At this point, use methods such as isValid() and moveTo() to do what you will with the files.328

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

Saved successfully!

Ooh no, something went wrong!