how upload pdf file mime type in javascript [Resolved]

Posted by Cpatil1000 under ASP.NET on 9/18/2016 | Points: 10 | Views : 471 | Status : [Member] | Replies : 2
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;
try
{
buffer = r.ReadByte();
fileclass = buffer.ToString();
buffer = r.ReadByte();
fileclass += buffer.ToString();
}
catch
{
}
r.Close();
if(fileclass!=“3780”)
{
ltl_status.Text = "<p>Error - The upload file must be in PDF format.</p>"
return;
}
}





Responses

Posted by: Rajnilari2015 on: 9/19/2016 [Member] [Microsoft_MVP] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Try this http://stackoverflow.com/questions/18299806/how-to-check-file-mime-type-with-javascript-before-upload which answers your question. Let us know if you find difficulty in understanding.

Thanks.

--
Thanks & Regards,
RNA Team

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Marieclaire on: 9/19/2016 [Member] Starter | Points: 25

Up
0
Down
Now it is easy to understand the concept for uploading the file with the help of these tags now students can easily submit their assignment without any need of [url=http://www.assignmentdesk.co.uk/] assignment help[/url] from experts.

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response