Return a PHP page as an image

The PHP Manual has this example: <?php // open the file in a binary mode $name=”./img/ok.png”; $fp = fopen($name, ‘rb’); // send the right headers header(“Content-Type: image/png”); header(“Content-Length: ” . filesize($name)); // dump the picture and stop the script fpassthru($fp); exit; ?> The important points is that you must send a Content-Type header. Also, you … Read more

How to determine MIME type of file in android?

First and foremost, you should consider calling MimeTypeMap#getMimeTypeFromExtension(), like this: // url = file path or whatever suitable URL you want. public static String getMimeType(String url) { String type = null; String extension = MimeTypeMap.getFileExtensionFromUrl(url); if (extension != null) { type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension); } return type; }

Stylesheet not loaded because of MIME-type

For Node.js applications, check your configuration: app.use(express.static(__dirname + ‘/public’)); Notice that /public does not have a forward slash at the end, so you will need to include it in your href option of your HTML: href=”https://stackoverflow.com/css/style.css”> If you did include a forward slash (/public/) then you can just do href=”https://stackoverflow.com/questions/48248832/css/style.css”.

Using .NET, how can you find the mime type of a file based on the file signature not the extension

I did use urlmon.dll in the end. I thought there would be an easier way but this works. I include the code to help anyone else and allow me to find it again if I need it. using System.Runtime.InteropServices; … [DllImport(@”urlmon.dll”, CharSet = CharSet.Auto)] private extern static System.UInt32 FindMimeFromData( System.UInt32 pBC, [MarshalAs(UnmanagedType.LPStr)] System.String pwzUrl, [MarshalAs(UnmanagedType.LPArray)] … Read more