PHP can obtain the file extension in four ways ,. PHP provides four methods for obtaining the file extension. This article describes four methods for obtaining the file extension by PHP. For your reference, refer to "export filename123.jpg". Method 1: four methods for obtaining file extensions in PHP,
This article describes four methods for obtaining the file extension of PHP. We will share this with you for your reference. The details are as follows:
$ Filename = "123.jpg"; // Method 1: function get_ext ($ file_name) {return array_pop (explode ('. ', $ file_name); // use. grouping strings} echo get_ext ($ filename); // Method 2: $ fileEx = strtolower (substr (strrchr ($ filename ,". "), 1); echo $ fileEx; // method 3: $ extend = pathinfo ($ filename); echo $ extend ['extension']; // method 4: $ filetype = array ("image/gif", "image/jpeg "); // Determine whether the file extension type is in this array if (in_array ($ _ FILES ['file'] ['type'], $ filetype )) {// Determine echo $ _ FILES ['file'] ['type'] for uploaded FILES;}
I hope this article will help you with PHP programming.
Example: This article describes four methods for PHP to obtain the file extension. For your reference, see $ filename = "123.jpg"; // method 1...