How can the file extension of an uploaded file be extracted from the $_FILES[] superglobal in PHP?
To extract the file extension of an uploaded file from the $_FILES[] superglobal in PHP, you can use the pathinfo() function to get the extension. This function returns an associative array containing information about the file path. You can then access the 'extension' key to get the file extension.
$fileExtension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
echo "File extension: " . $fileExtension;
Keywords
Related Questions
- How can PHP developers ensure that customer data, such as customer numbers and passwords, are securely transmitted and stored in databases?
- What are some common issues with using single and double quotes in PHP when generating HTML output?
- What are the potential pitfalls of using fopen to check URL existence in PHP?