This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “Uploading Files with PHP”.
1. Which directive determines whether PHP scripts on the server can accept file uploads?
Explanation: With PHP, it is easy to upload files to the server. We need to ensure that PHP is configured to allow file uploads. In the “php.ini” file, search for the file_uploads directive, and set it to On. By default, its value is on.
2. Which of the following directive determines the maximum amount of time that a PHP script will spend attempting to parse input before registering a fatal error?
Explanation: This is relevant because particularly large files can take some time to upload, eclipsing the time set by this directive.
3. What is the default value of max_input_time directive?
a) 30 seconds
b) 60 seconds
c) 120 seconds
d) 1 second
Explanation: The default value of the max_input_time directive is 60 seconds.
4. Since which version of PHP was the directive max_file_limit available.
a) PHP 5.2.1
b) PHP 5.2.2
c) PHP 5.2.12
d) PHP 5.2.21
Explanation: The max_file_limit directive sets an upper limit on the number of files which can be simultaneously uploaded.
5. What is the default value of the directive max_file_limit?
a) 10 files
b) 15 files
c) 20 files
d) 25 files
Explanation: The default value of the directive max_file_limit is 20 files.
6. Which directive sets a maximum allowable amount of memory in megabytes that a script can allow?
Explanation: Its default value is 16M.
7. If you want to temporarily store uploaded files in the /tmp/phpuploads/ directory, which one of the following statement will you use?
a) upload_tmp_dir “/tmp/phpuploads/ directory”
b) upload_dir “/tmp/phpuploads/ directory”
c) upload_temp_dir “/tmp/phpuploads/ directory”
d) upload_temp_director “/tmp/phpuploads/ directory”
Explanation: Anyone can temporarily store uploaded files on the given directory. One cannot change upload_tmp_dir at the runtime. By the time a script runs, the upload process has already occurred.
8. Which superglobal stores a variety of information pertinent to a file uploaded to the server via a PHP script?
a) $_FILE Array
b) $_FILES Array
c) $_FILES_UPLOADED Array
d) $_FILE_UPLOADED Array
Explanation: The superglobal $_FILES is a two-dimensional associative global array of items which are being uploaded by via HTTP POST method and holds the attributes of files.
9. How many items are available in the $_FILES array?
Explanation: $_FILEs[‘userfile’][‘error’], $_FILEs[‘userfile’][‘name’], $_FILEs[‘userfile’][‘size’], $_FILEs[‘userfile’][‘tmp_name’], $_FILEs[‘userfile’][‘type’] are the five items in the array.
10. Which function is used to determine whether a file was uploaded?
Explanation: The function is_uploaded_file() checks whether the specified file is uploaded via HTTP POST. The syntax is is_uploaded_file(file).
Sanfoundry Global Education & Learning Series – PHP Programming.
To practice all questions on PHP Programming, here is complete set of 1000+ Multiple Choice Questions and Answers on PHP.