You must Sign In to post a response.
  • Category: ASP.NET

    How upload mime type in javascript

    I am developing an app where a user uploads PDF files to the server, via a FileUpload control.

    As part of the usual security/reliability checks I wanted to verify that the uploaded document was actually
    a PDF, not just say, a Text file renamed to have a .PDF extension. Now i want in javascript. means client site.

    protected void Button1_Click(object sender, EventArgs e)
    System.IO.BinaryReader r = new System.IO.BinaryReader(FileUpload2.PostedFile.InputStream);
    string fileclass = "";
    byte buffer;
    buffer = r.ReadByte();
    fileclass = buffer.ToString();
    buffer = r.ReadByte();
    fileclass += buffer.ToString();
    ltl_status.Text = "<p>Error - The upload file must be in PDF format.</p>"
  • #768495
    For PDF, standard MIME type is 'application/pdf'.
    Please refer this also:

  • #768514
    You can try this to upload mime type in javascript
    <input type="file" id="your-files" multiple>
    var control = document.getElementById("your-files");
    control.addEventListener("change", function(event) {
    var files = control.files,
    for (var i = 0; i < files.length; i++) {
    console.log("Filename: " + files[i].name);
    console.log("Type: " + files[i].type);
    console.log("Size: " + files[i].size + " bytes");
    }, false);

  • Sign In to post your comments