Prev | Current Page 460 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

Therefore, if
you browse to a file named vacation.png and upload it via the form, this variable
will be assigned the value vacation.png.
??? $_FILES['userfile']['size']: This variable specifies the size, in bytes, of the
file uploaded from the client machine. Therefore, in the case of the vacation.png
file, this variable could plausibly be assigned a value such as 5253, or roughly 5KB.
??? $_FILES['userfile']['tmp_name']: This variable specifies the temporary name
assigned to the file once it has been uploaded to the server. This is the name of
the file assigned to it while stored in the temporary directory (specified by the
PHP directive upload_tmp_dir).
??? $_FILES['userfile']['type']: This variable specifies the MIME type of the file
uploaded from the client machine. Therefore, in the case of the vacation.png
image file, this variable would be assigned the value image/png. If a PDF were
uploaded, the value application/pdf would be assigned. Because this variable
sometimes produces unexpected results, you should explicitly verify it yourself
from within the script.
PHP??™s File-Upload Functions
In addition to the host of file-handling functions made available via PHP??™s file
system library (see Chapter 10 for more information), PHP offers two functions
specifically intended to aid in the file-upload process, is_uploaded_file() and
move_uploaded_file(). This section introduces each function.


Pages:
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472