$_FILES['classnotes']['name']);
Of course, you could rename the file to anything you wish when it??™s moved. It??™s
important, however, that you properly reference the file??™s temporary name within
the first (source) parameter.
Upload Error Messages
Like any other application component involving user interaction, you need a means
to assess the outcome, successful or otherwise. How do you definitively know that the
file-upload procedure was successful? And if something goes awry during the upload
process, how do you know what caused the error? Thankfully, sufficient information
for determining the outcome, and in the case of an error, the reason for the error, is
provided in $_FILES['userfile']['error']:
??? UPLOAD_ERR_OK: A value of 0 is returned if the upload is successful.
??? UPLOAD_ERR_INI_SIZE: A value of 1 is returned if there is an attempt to upload a
file whose size exceeds the value specified by the upload_max_filesize directive.
??? UPLOAD_ERR_FORM_SIZE: A value of 2 is returned if there is an attempt to upload
a file whose size exceeds the value of the max_file_size directive, which can be
embedded into the HTML form.
?– Note Because the max_file_size directive is embedded within the HTML form, it can easily be
modified by an enterprising attacker. Therefore, always use PHP??™s server-side settings (upload_max_
filesize, post_max_filesize) to ensure that such predetermined absolutes are not surpassed.
Pages:
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475