Prev | Current Page 158 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"

This superglobal is a tad different from the others in that it is a
two-dimensional array containing five elements. The first subscript refers to the name
of the form??™s file-upload form element; the second is one of five predefined subscripts
that describe a particular attribute of the uploaded file:
$_FILES['upload-name']['name']: The name of the file as uploaded from the client
to the server.
$_FILES['upload-name']['type']: The MIME type of the uploaded file. Whether
this variable is assigned depends on the browser capabilities.
$_FILES['upload-name']['size']: The byte size of the uploaded file.
$_FILES['upload-name']['tmp_name']: Once uploaded, the file will be assigned a
temporary name before it is moved to its final location.
CHAPTER 3 ?–  PHP BASICS 85
$_FILES['upload-name']['error']: An upload status code. Despite the name, this
variable will be populated even in the case of success. There are five possible values:
??? UPLOAD_ERR_OK: The file was successfully uploaded.
??? UPLOAD_ERR_INI_SIZE: The file size exceeds the maximum size imposed by the
upload_max_filesize directive.
??? UPLOAD_ERR_FORM_SIZE: The file size exceeds the maximum size imposed by an
optional MAX_FILE_SIZE hidden form-field parameter.
??? UPLOAD_ERR_PARTIAL: The file was only partially uploaded.
??? UPLOAD_ERR_NO_FILE: A file was not specified in the upload form prompt.
Chapter 15 is devoted to a complete introduction of PHP??™s file-upload functionality.


Pages:
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170