php - Suggest file extension from file type -


i have image file name without extension (lets assume image_file_name - note missing extension) , know file type (lets assume file type image/jpeg). there php function returns file extension given type? explained in following pseudo code:

$extension = get_extension('image/jpeg'); // return 'jpg'  $file_name = 'image_file_name' . '.' . $extension; // result in $file_name = image_file_name.jpg 

please note image above example, file name of file type, such web page file name or else. , extension well, html, css ...etc.

is possible above? , how?

$ext = substr(image_type_to_extension(exif_imagetype('dev.png')), 1); //example png 

this give extension correctly , more reliable $_file['image']['type'].


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -