This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “Image Uploading Ability”.
1. Before you can start processing images with PHP, you must first add the ability to upload images to your administrative form on ________
a) .htaccess
b) function.inc.php
c) index.php
d) admin.php
View Answer
Explanation: To do this, you’ need to add a file upload input to your administrative form.
2. When you’re uploading files you need to set the enctype of the form to __________
a) text
b) text/file
c) multipart/form-data
d) multimedia/form-data
View Answer
Explanation: Set the enctype of the form to multipart/form-data, which can accept files and standard form values.
3. To check whether a file was uploaded, you look in the _______ superglobal array.
a) $_FILES
b) $_DOCS
c) $_DOCUMENTS
d) $_FOLDERS
View Answer
Explanation: Whenever a file is uploaded via an HTML form, that file is stored in temporary memory and information about the file is passed in the $_FILES superglobal.
4. To make the ImageHandler class portable you should create a separate file for it called __________
a) imagehandler.inc.php
b) images.inc.php
c) handler.inc.php
d) imghandler.inc.php
View Answer
Explanation: You save this file in the inc folder (full path: /xampp/htdocs/simple_blog/inc/images.inc.php).
5. DocBlocks are indicated by opening a comment using _________
a) /*
b) //*
c) /**
d) /*/
View Answer
Explanation: This is a special comment that provides information about a class, property, or method.
6. To process the file, you need to break the array from $_FILES into individual values. You can do this using the ________ function.
a) divide()
b) list()
c) break()
d) indi()
View Answer
Explanation: The list() function allows you to create named variables for each array index as a comma-separated list.
7. Before you try to process the file, you need to make sure that your $err value is equivalent to _________
a) UPLOAD_ERR_OK
b) UPLOAD_NO_ERR
c) UPLOAD_ERR_NO_OK
d) UPLOAD_ERR
View Answer
Explanation: When you’re dealing with files uploaded through an HTML form, you have access to a special constant called UPLOAD_ERR_OK that tells you whether a file uploaded successfully.
8. You use the $_SERVER superglobal and your _______ property to create your path to check.
a) $load_dir
b) $load
c) $save
d) $save_dir
View Answer
Explanation: // Determines the path to check
$path = $_SERVER['DOCUMENT_ROOT'] . $this->save_dir;
9. Which function do you have to use to check whether the $path you’ve stored exists?
a) path_dir()
b) path()
c) is_dir()
d) path_dir()
View Answer
Explanation: If the path exists, is_dir() returns TRUE; otherwise, it returns FALSE.
10. Which one of the following is true about the following line – $obj = new ImageHandler(‘/images/’, array(400, 300));?
a) This snippet sets the maximum dimensions allowed to 400 pixels wide by 300 pixels high
b) This snippet sets the minimum dimensions allowed to 300 pixels wide by 400 pixels high
c) This snippet sets the minimum dimensions allowed to 400 pixels wide by 300 pixels high
d) This snippet sets the maximum dimensions allowed to 300 pixels wide by 400 pixels high
View Answer
Explanation: If you needed to change the size of your images, you can change the dimensions using the above instantiation of ImageHandler.
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.
- Apply for Programming Internship
- Check Information Technology Books
- Check MCA Books
- Practice Programming MCQs
- Check PHP Books