Prev | Current Page 467 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

By default, these messages are in English; however, HTTP_Upload
supports seven languages: Dutch (nl), English (en), French (fr), German (de),
CHAPTER 15 ?–  HANDL ING F ILE UPLOADS 397
Italian (it), Portuguese (pt_BR), and Spanish (es). To change the default error language,
invoke the HTTP_Upload() constructor using the appropriate abbreviation. For example,
to change the language to Spanish, invoke the constructor like so:
$upload = new HTTP_Upload('es');
Learning More About an Uploaded File
In this first example, you find out how easy it is to retrieve information about an
uploaded file. Again we??™ll use the form presented in Listing 15-1, this time pointing
the form action to uploadprops.php, found in Listing 15-3.
Listing 15-3. Using HTTP_Upload to Retrieve File Properties (uploadprops.php)
require('HTTP/Upload.php');
// New HTTP_Upload object
$upload = new HTTP_Upload();
// Retrieve the classnotes file
$file = $upload->getFiles('classnotes');
// Load the file properties to associative array
$props = $file->getProp();
// Output the properties
print_r($props);
?>
Uploading a file named notes.txt and executing Listing 15-3 produces the
following output:
Array (
[real] => notes.txt
[name] => notes.txt
[form_name] => classnotes
[ext] => txt
[tmp_name] => /tmp/B723k_ka43
398 CHAPTER 15 ?–  HANDL ING F ILE UPLOADS
[size] => 22616
[type] => text/plain
[error] =>
)
The key values and their respective properties are discussed earlier in this chapter,
so there??™s no reason to describe them again (besides, all the names are rather selfexplanatory).


Pages:
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479