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?
a) file_uploads
b) file_upload
c) file_input
d) file_intake
View Answer
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?
a) max_take_time
b) max_intake_time
c) max_input_time
d) max_parse_time
View Answer
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
View Answer
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
View Answer
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
View Answer
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?
a) max_size
b) post_max_size
c) max_memory_limit
d) memory_limit
View Answer
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”
View Answer
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
View Answer
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?
a) 2
b) 3
c) 4
d) 5
View Answer
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?
a) is_file_uploaded()
b) is_uploaded_file()
c) file_uploaded(“filename”)
d) uploaded_file(“filename”)
View Answer
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.
- Practice MCA MCQs
- Check MCA Books
- Check PHP Books
- Practice Programming MCQs
- Apply for Programming Internship