Why Is Mime_Content_Type() Deprecated in PHP

Why is mime_content_type() deprecated in PHP?

I guess it's because Fileinfo can return more information about files.

EDIT: Here is a replacement hack:

function _mime_content_type($filename) {
$result = new finfo();

if (is_resource($result) === true) {
return $result->file($filename, FILEINFO_MIME_TYPE);
}

return false;
}

PHP: where is the mime_content_type function?

mime_content_type is not deprecated. It was apparently just a mistake in the documentation.

See this bug report

mime_content_type() support in php

The mime_content_type error is due to it not being available in your PHP build (it has been deprecated for some time now). But you could create that function yourself: http://php.net/mime_content_type

If you are using the latest version of the class, you can also override the mime type by passing 'Content-Type' => 'your-mime-type' to putObject()'s $requestHeaders. See: https://github.com/tpyo/amazon-s3-php-class#uploading-objects

There is an update in the works to allow custom mime lookup callbacks too.

mime_content_type(): Invalid path

mime_content_type requires path to the tested file, not just base64 string. But why are you trying to recognize mime type when you know it is image/jpeg (by imagejpeg function).

$src = "data:image/jpeg;base64," . $imageData;


Related Topics



Leave a reply



Submit