Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get File Type by URL for a Remote File in WordPress
<?php
/**
* Get the file mime type for a file by its URL.
*
* @param $url The URL to the file.
* @return The file mime type or empty string on failure.
*/
function km_get_file_type_by_url( $url ) {
$response = wp_remote_get( $url );
return wp_remote_retrieve_header( $response, 'content-type' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.