If i upload a file test.exe, then my application restricts it and give an alert message.
But, if i rename the file as test.exe.txt the application uploads it in database successfully.
How to restrict the upload for test.exe.txt or test.zip.txt?
Please suggest.
Thanks,
Sneha.
What I have tried:
I have tried restricting the contenttype of a file but it is not working as required.
for ex:
If (fuAttachment.PostedFile.ContentType <> " text/HTML" And fuAttachment.PostedFile.ContentType <> " text/plain" And fuAttachment.PostedFile.ContentType <> " Application/msword" And fuAttachment.PostedFile.ContentType <> " image/jpeg" And fuAttachment.PostedFile.ContentType <> " image/GIF" And fuAttachment.PostedFile.ContentType <> " application/pdf" And fuAttachment.PostedFile.ContentType <> " Application/x-msexcel" And fuAttachment.PostedFile.ContentType <> " image/bmp" And fuAttachment.PostedFile.ContentType <> " application/vnd.ms-outlook" And fuAttachment.PostedFile.ContentType <> " image/tiff" And fuAttachment.PostedFile.ContentType <> " video/mp4" And fuAttachment.PostedFile.ContentType <> " application/rar" And fuAttachment.PostedFile.ContentType <> " video/mpeg" ) Then lblMsg.Visible = True lblMsg.Text = " Upload JPG / BMP / JPEG / TIF / PDF / Doc / Excel / Zip format / MP4 / MPEG / MPG/ RAR / TXT / HTML / MSG files only" Return False Exit Try
  • Read the question carefully.
  • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  • Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
  •