Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
reading file content type with asp
Old 05-18-2006, 07:50 AM reading file content type with asp
Junior Talker

Posts: 2
Trades: 0
Hello,

Does any one know how i can read the file scontent type from a file in a upload folder?

this is the code that i have:

Code:
<select name="selectFile" onChange="MM_jumpMenu('parent',this,0)">
                      <% 
      ' Reads in the files out of this folder... yey
      Dim fso
       Set fso = Server.CreateObject("Scripting.FileSystemObject")
      Dim rootFolder
       Set rootFolder = fso.GetFolder(Server.MapPath("../../main_site/pages/about/vacancies/uploads/"))
      ' Stores true if at least one file was found
      dim fileFound
       fileFound = false
 
      ' Loops through every file in this folder
      For Each file in rootFolder.Files
       ' Checks to see if it a doc file
       if [ files contenttype here ] <> "application/msword" then
 
        ' If not then we just delete it has it should be there anyway
        fso.DeleteFile(rootFolder & "\" &  file.Name)
       else
        fileFound = true
        ' For each of thse files, check the database see if it is attached to this job already
        Response.Write("<option>" & fso.getBaseName(file.Name) & "</option>")
       end if
      Next
      if fileFound = false then 
       %><option selected>None Available</option><% 
      end if
 
      Set files = Nothing
      Set subFolders = Nothing
      Set rootFolder = Nothing
      Set fso = Nothing
     %>
                  </select>
where it says the "[ files contenttype here ] " i want to replace that with what ever the files content tye is, like file.contenttype or something

Any ideas?

David
davidmp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-18-2006, 10:20 AM Re: reading file content type with asp
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You can use objFso.GetExtensionName(filepath) to get the document file extension but as far as I am aware you cannot get the MIME types using ASP
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-18-2006, 10:37 AM Re: reading file content type with asp
Junior Talker

Posts: 2
Trades: 0
Thanks for replying,

I am currently using the method you said, but its really easy to change the extension to something else and have it fool the computer.

I have checked for the .doc, and told it to delete anything else it finds in the folder that is not .doc, i was going to use the content type as i used a uploader tutorial and that allowed me to get the content type from the uploaded files and block anything that is not application/msword.

It doesnt look like there is a way to read the MIME types, or what ever sites i look on there doesnt seem to be a method.

Ill let you know anyways

David
davidmp is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to reading file content type with asp
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.39970 seconds with 12 queries