PHP Questions and Answers - PHP Files Uploading

1. The authenticationFile.txt, the file which stores username and password should be stored ___ the server document root.
a) Inside
b) Outside
c) Within
d) None of the mentioned

  Discussion

Answer: b
Explanation: If it is not stored outside, the attacker could discover the file through brute force guessing.

2. Which function is used to split a string into a series of substrings, with each string boundary is determined by a specific separator?
a) break()
b) divide()
c) explode()
d) md5()

  Discussion

Answer: c
Explanation: Although they are a similar function, you should use explode() instead of split(). In fact split() function has been deprecated altogether.

3. In which of the following situations does file-based authentication become inconvenient.
i) small list
ii) large number of user
iii) users are being regularly added
iv) static authentication
a) i) and iv)
b) i) and iii)
c) ii) and iii)
d) ii) and iv)

  Discussion

Answer: c
Explanation: Such requirements are better satisfied by implementing a database based solution.

4. Which is the most powerful authentication method among the four?
a) Hard-coding a login pair directly into the script
b) File-based authentication
c) Data-based authentication
d) PEAR’S HTTP authentication

  Discussion

Answer: c
Explanation: It not only enhances administrative convenience and scalability but also can be integrated into a larger database infrastructure.

5. 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

  Discussion

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.

6. 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

  Discussion

Answer: c
Explanation: This is relevant because particularly large files can take some time to upload, eclipsing the time set by this directive.

7. What is the default value of max_input_time directive?
a) 30 seconds
b) 60 seconds
c) 120 seconds
d) 1 second

  Discussion

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

8. 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

  Discussion

Answer: c
Explanation: The max_file_limit directive sets an upper limit on the number of files which can be simultaneously uploaded.

9. What is the default value of the directive max_file_limit?
a) 10 files
b) 15 files
c) 20 files
d) 25 files

  Discussion

Answer: c
Explanation: The default value of the directive max_file_limit is 20 files.

10. 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

  Discussion

Answer: d
Explanation: Its default value is 16M.