PHP Upload only image using file upload

PHP upload only images

In this php file upload tutorial we will learn to make restriction to upload image as per our requirement.
Here, we allow only images to be uploaded using file upload in php, so we need to check extension of uploaded file, to ensure that is image or not.

Here, we take a php file upload example that allow to upload only ‘jpg’, ‘jpeg’, ‘gif’ and ‘png’ image.

For check upload file extension.

pathinfo(“image_name”, PATHINFO_EXTENSION)


PHP File upload example

Example of check extension of uploading image.

The output of php example is :

php file upload

PHP upload image type check example


 

We can also do same above things usingĀ $_FILES[“file”][“type”] in php.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

7 + 6 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">