Forum Moderators: open

Message Too Old, No Replies

Excel filetype in ASP

for uploading

         

txbakers

11:06 pm on Oct 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a routine where people can upload an Excel file to the server and the ASP scripts will read it and insert the info into a database.

I check for the filetype before allowing the upload. It seems that XLS files have one of two mime types:

"application/vnd.ms-excel"
"application/octet-stream"

I need to check for both of these so the file can be uploaded.

Why is that?

TheNige

8:04 pm on Oct 28, 2005 (gmt 0)

10+ Year Member



I'm working on something similar. I just found out that it also depends on which machine I was uploading the file from.

I created a csv file in excel...save as CSV. Then from my dev machine uploaded it and the content type was "application/octet-stream". If I simply just saved it as an xls then it would show "application/vnd.ms-excel"

Now, I take that csv file that was showing up as "application/octet-stream" and upload it to the site from another machine it would show up as "application/vnd.ms-excel".

I'm confused too.

coopster

7:58 pm on Oct 31, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The mime type of the file during a file upload is controlled by the browser, if the browser provided this information. Not all browsers support MIME type associations. I'm trying to recall the relative RFC's ... I want to say RFC1867 was the original, and that is obsolete. You'll have to go from there if you want to dig deeper. Here nor there though, if the browser is offering it up you can have a look at it and if not, you'll have to figure out another way to analyze it. Perhaps by file extension as well as checking out the mime type.