I'm creating a file upload tool, and want to allow only DOC, XLS, PDF, RTF
or TXT files. I am using this to check:
if (contentType = "application/msword") _
or (contentType = "application/rtf") _
or (contentType = "application/ms-excel") _
or (contentType = "application/pdf") _
or (contentType = "application/txt") then
However, I'm not sure if that's the proper way...namly the 'msword' vs.
'ms-excel' (the two examples I found online).
Does the above look correct?
-Darrel 7 1460
How about just checking the file extension?
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"darrel" <no*****@hotmail.com> wrote in message
news:eq****************@tk2msftngp13.phx.gbl... I'm creating a file upload tool, and want to allow only DOC, XLS, PDF, RTF or TXT files. I am using this to check:
if (contentType = "application/msword") _ or (contentType = "application/rtf") _ or (contentType = "application/ms-excel") _ or (contentType = "application/pdf") _ or (contentType = "application/txt") then
However, I'm not sure if that's the proper way...namly the 'msword' vs. 'ms-excel' (the two examples I found online).
Does the above look correct?
-Darrel
> How about just checking the file extension?
That's what I'm falling back on. Does changing the extension also change the
content-type? If so, then I guess it makes sense to just test for the file
extension.
I'm avoiding the 'hmm...my powerpoint file won't upload...Oh...I'll just
change the file extension...' issue.
-Darrel
Okay, let's talk about Content type. It's an HTTP entity, that is, it is
used by internet web applications when sending a stream of data. It tells an
Intenet HTTP client what kind of file it is. However, although the client in
this case is sending the file, by the time your code gets to it, it's just a
file stream again. So, how does your OS determine what kind of file a file
is? It uses the file extension. So, how should you tell what kind of file it
is? Check the extension.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"darrel" <no*****@hotmail.com> wrote in message
news:Oo*************@TK2MSFTNGP12.phx.gbl... How about just checking the file extension?
That's what I'm falling back on. Does changing the extension also change the content-type? If so, then I guess it makes sense to just test for the file extension.
I'm avoiding the 'hmm...my powerpoint file won't upload...Oh...I'll just change the file extension...' issue.
-Darrel
> Okay, let's talk about Content type. It's an HTTP entity, that is, it is used by internet web applications when sending a stream of data. It tells
an Intenet HTTP client what kind of file it is. However, although the client
in this case is sending the file, by the time your code gets to it, it's just
a file stream again. So, how does your OS determine what kind of file a file is? It uses the file extension. So, how should you tell what kind of file
it is? Check the extension.
Ah, so, what, exactly, is the point in grabbing the contentType if it simply
is based of the file extension?
Sounds like they are the same thing, at least when reading the file in.
-Darrel
> Ah, so, what, exactly, is the point in grabbing the contentType if it simply is based of the file extension?
I didn't say there WAS any point to doing that! There IS no point to it.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... Okay, let's talk about Content type. It's an HTTP entity, that is, it is used by internet web applications when sending a stream of data. It tells an Intenet HTTP client what kind of file it is. However, although the client in this case is sending the file, by the time your code gets to it, it's just a file stream again. So, how does your OS determine what kind of file a file is? It uses the file extension. So, how should you tell what kind of file it is? Check the extension.
Ah, so, what, exactly, is the point in grabbing the contentType if it simply is based of the file extension?
Sounds like they are the same thing, at least when reading the file in.
-Darrel
> I didn't say there WAS any point to doing that! There IS no point to it.
Good to know! Thanks.
-Darrel
when the browser uploads a file, it does not work hard to get a mime-type,
it usually sends, text, xml or binary (requires encoding). so you need to
check the file extension it supplies as it will be more accurate.
-- bruce (sqlwork.com)
"darrel" <no*****@hotmail.com> wrote in message
news:eq****************@tk2msftngp13.phx.gbl... I'm creating a file upload tool, and want to allow only DOC, XLS, PDF, RTF or TXT files. I am using this to check:
if (contentType = "application/msword") _ or (contentType = "application/rtf") _ or (contentType = "application/ms-excel") _ or (contentType = "application/pdf") _ or (contentType = "application/txt") then
However, I'm not sure if that's the proper way...namly the 'msword' vs. 'ms-excel' (the two examples I found online).
Does the above look correct?
-Darrel
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Webgour |
last post by:
How do you reproduce this vbscript in C#
<%
Response.ContentType = "text/plain"
response.write "This is text type"
%>
|
by: Bryan Glennon |
last post by:
I have an aspx page. If I set the Response.ContentType =
"application/voicexml+xml" then when I load browse to the page it
downloads the file and opens .Net Studio to allow me to edit it. It...
|
by: David Lozzi |
last post by:
Hello, this is a repost of a previous post of mine from today.
I need to export multiple documents (doc, xls, ppt, jpg) and crystal reports to a single PDF file. I know how to export a single...
|
by: ad |
last post by:
I create a MemoryStream form a dataset:
MemoryStream sm= new MemoryStream();
dsHealth.WriteXml(sm);
I use
Response.Write()
to send this XML MemoryStream as file to client.
What is the...
|
by: Carstonio |
last post by:
I use ASP to display links to Word documents on an intranet. Is there a way
in ASP to do text searches on the documents' contents? I want the results to
have the link to the Word document plus two...
|
by: Roel |
last post by:
Hi all,
I'm using the FileUpload control for uploading MS Word and MS PowerPoint
documents.
To check if a user uploads a correct document, I check the contenttype...
|
by: rguarnieri |
last post by:
Hi!, I'm using Visual Studio 6.0 and I'm trying to open an asp page
like a .pdf file, I used
Response.ContentType="application/pdf" in my asp page but it doesn't
work
This is an example:
<%@...
|
by: Neil |
last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text
feature does not support: a) full text justification; b) programmatic
manipulation.
I was hoping that someone might...
|
by: SteveB |
last post by:
I have posted this question in the Visual Basic 2005 and Visual
Basic .Net 2005 discussion groups, also.
Hi. I am developing an application/web page with VB.Net that will
populate a SQL...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |