SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: CSV MIME Types

  1. #1
    Learning...
    Join Date
    Jan 2003
    Posts
    781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry CSV MIME Types

    What is the Mime Type for CSV Extensions?

    Is it "application/vnd.ms-excel" or "text/comma-separated-values" or it is some thing else? I have searched the web and found different types. The most common ones are the 2 i have put here.

    If any one wants it, i have a list of most common file extension mime types. This is a function to which you pass the file extention and it will return you the Mim Type. If the Mime Typs is not found it will return empty string.

    function GetMIMeType(cExt){
    var cExt = new String(cExt);
    cExt = cExt.toUpperCase();

    if(cExt == "TXT" || cExt == "TEXT" || cExt == "JS" )
    return "text/plain";
    else if(cExt == "CSV" )
    return "text/comma-separated-values"
    else if(cExt == "HTM" || cExt == "HTML" || cExt == "ASP" || cExt == "CGI" || cExt == "PL" )
    return "text/html";
    else if(cExt == "PDF" )
    return "application/pdf";
    else if(cExt == "RTF" )
    return "text/richtext";
    else if(cExt == "XML" )
    return "text/xml";
    else if(cExt == "WPD" )
    return "application/wordperfect";
    else if(cExt == "WRI" )
    return "application/mswrite";
    else if(cExt == "XLS" || cExt == "XLS3" || cExt == "XLS4" || cExt == "XLS5" || cExt == "XLW" )
    return "application/msexcel";
    else if (cExt == "DOC" )
    return "application/msword";
    else if (cExt == "PPT" || cExt == "PPS" )
    return "application/mspowerpoint";
    else if (cExt == "WML" )
    return "text/vnd.wap.wml";
    else if (cExt == "WMLS" )
    return "text/vnd.wap.wmlscript";
    else if (cExt == "WBMP" )
    return "image/vnd.wap.wbmp";
    else if (cExt == "WMLC" )
    return "application/vnd.wap.wmlc";
    else if (cExt == "WMLSC" )
    return "application/vnd.wap.wmlscriptc";
    else if (cExt == "GIF" )
    return "image/gif";
    else if (cExt == "JPG" || cExt == "JPE" || cExt == "JPEG" )
    return "image/jpeg";
    else if (cExt == "PNG" )
    return "image/x-png";
    else if (cExt == "BMP" )
    return "image/bmp";
    else if (cExt == "TIF" || cExt == "TIFF" )
    return "image/tiff";
    else if(cExt == "XWD" )
    return "image/x-xwindowdump";
    else if(cExt == "IEF" )
    return "image/ief";
    else if (cExt == "AI" || cExt == "EPS" || cExt == "PS" )
    return "application/postscript";
    else if (cExt == "AU" || cExt == "SND" )
    return "audio/basic";
    else if (cExt == "WAV" )
    return "audio/wav";
    else if (cExt == "RA" || cExt == "RM" || cExt == "RAM" )
    return "audio/x-pn-realaudio";
    else if (cExt == "MID" || cExt == "MIDI" )
    return "audio/x-midi";
    else if (cExt == "MP3" )
    return "audio/mp3";
    else if (cExt == "M3U" )
    return "audio/m3u";
    else if (cExt == "AVI" )
    return "video/avi";
    else if (cExt == "MPG" || cExt == "MPEG" || cCat == "MPE" )
    return "video/mpeg";
    else if (cExt == "QT" || cExt == "MOV" || cExt == "QTVR" )
    return "video/quicktime";
    else if(cExt == "MOVIE" )
    return "video/x-sgi-movie";
    else if (cExt == "SWA" )
    return "application/x-director";
    else if (cExt == "SWF" )
    return "application/x-shockwave-flash";
    else if (cExt == "COM" || cExt == "EXE" || cExt == "DLL" || cExt == "OCX" )
    return "application/octet-stream";
    else if (cExt == "PDB" )
    return "chemical/x-pdb";
    else if (cExt == "ZIP" )
    return "application/x-zip-compressed";
    else
    return "";
    }
    Last edited by tahirjadoon; Oct 28, 2003 at 14:44.

  2. #2
    SitePoint Zealot -rob-'s Avatar
    Join Date
    Mar 2003
    Location
    Earth
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no official RFC document for CSV files, but they are a flat text file so the best MIME type to use would be text/plain.

    There are OS specific MIME implementations for CSV files. For example Microsoft use application/vnd.ms-excel.
    Cheers,

    -rob-

  3. #3
    Learning...
    Join Date
    Jan 2003
    Posts
    781
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Rob, your answer helped me a great deal and i have upgraded my MIME typefunction.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •