Displaying different MIME types in a browser

I am looking at writing a browser application, that can display content that is of different MIME types. The main content types are application, message, image, audio and multipart.

Now, I do not know a lot about the different content types, and how it will be handled by the browser. Most clients will use Chrome, so answers relating to Chrome will be great. The content will be provided by the client, so my main concern at this point is the display thereof.

My idea at the moment is to have an iframe within my browser application, and this iframe will get the value of the content that needs to be displayed. Is this necessarily a good ideas or are there any better alternative solutions?

I have two related questions at this moment:

  • Will the browser change the display according to the MIME type?

  • Do I have to specify the CSS for each MIME type I would like to support?

  • If if sounds as if I have no clue, it is probably because I don't :) that is why I think it would be good to have a discussion with someone who knows a bit more.

    Thanks!


    For browser to display some file content you must properly set Content-Type headers. You can't do that using html/css. Use some back-end language like PHP.

    $path = 'uploads/1554/my_uploaded.jpg';
    $mime = mime_content_type($path);
    header('Content-Type: '.$mime); // "Content-Type: image/jpg"
    echo file_get_contents($path);
    
    exit();
    

    Properly validate user uploaded files, at it may contain some malicious code that can expose access to your system.

    链接地址: http://www.djcxy.com/p/47050.html

    上一篇: $(document).ready()和脚本位置

    下一篇: 在浏览器中显示不同的MIME类型