PHP Questions & Answers – Uploading Files with PHP

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

Answer: a
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

Answer: c
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

Answer: b
Explanation: The default value of the max_input_time directive is 60 seconds.
advertisement
advertisement

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

Answer: c
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

Answer: c
Explanation: The default value of the directive max_file_limit is 20 files.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

Answer: d
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

Answer: a
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.
advertisement

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

Answer: b
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

Answer: d
Explanation: $_FILEs[‘userfile’][‘error’], $_FILEs[‘userfile’][‘name’], $_FILEs[‘userfile’][‘size’], $_FILEs[‘userfile’][‘tmp_name’], $_FILEs[‘userfile’][‘type’] are the five items in the array.
advertisement

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

Answer: b
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.