No need to use string functions. You can use something that’s actually designed for what you want: pathinfo()
:
$path = $_FILES['image']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);
More Related Contents:
- How to get a file’s extension in PHP?
- Codeigniter multiple file upload messes file extension
- How to get only images using scandir in PHP?
- Why hash_equals and password_verify are not working properly?
- How do I pass JavaScript variables to PHP?
- PHP method chaining or fluent interface?
- Mysqli update throwing Call to a member function bind_param() error [duplicate]
- Logical Operators, || or OR?
- HTTP Headers for File Downloads
- PHP Fatal error: Call to undefined function mssql_connect()
- How do I remove all specific characters at the end of a string in PHP?
- Upload max size in PHP?
- how safe are PDO prepared statements
- filter values from an array similar to SQL LIKE ‘%search%’ using PHP
- How to partially download a remote file with cURL?
- Laravel stylesheets and javascript don’t load for non-base routes
- Laravel: validate an integer field that needs to be greater than another
- Output raw XML using php
- Laravel Request::all() Should Not Be Called Statically
- How to connect to MySQL database in PHP using mysqli extension?
- How to “Validate” Human Names in CakePHP?
- PHP Check for NULL
- How to create an empty array in PHP with predefined size?
- Laravel Livewire component not refreshing/reloading automatically after refreshing it
- How to use phpexcel to read data and insert into database?
- How do you pass objects by reference in PHP 5?
- how do I get all checkbox variables even if not checked from HTML to PHP?
- Using namespaces in Laravel 4
- How do i search from serialize field in mysql database?
- How to insert into MySQL using mysqli