SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    MIME type of a file

    im just wondering, since just checking the ext of a certain file is not enough
    how can i check the mime type of an uploaded file to check if the file really is an image?

    Thanks in advance,
    Ulthane

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    perhaps check for image dimensions to see if it really is an image

    http://forums.aspfree.com/code-bank-...ns-196351.html

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    tried to combine that code with the uploading form code i got atm but had no luck apperantly..keep getitng alot of different errors..

  4. #4
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    690
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you'll have to be a bit more specific if there is any expectation for help.

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    i cannot really be more specific, i can just show u my current code and u'll help me combining the image deminsions check with it if u can

    Code:
    <!--#INCLUDE FILE="clsUpload.asp"-->
    <%
    Dim Upload
    Dim FileName
    Dim Folder
    
    Set Upload = New clsUpload
    
    FileName =LCase(Upload.Fields("File1").FileName)
    
    If Right (FileName,4) = ".jpg" or Right (FileName,4) = ".bmp" or Right (FileName,4) = ".png" or Right (FileName,4) = ".gif" or Right (FileName,5) = ".jpeg" Then 
        If Upload("File1").Length < 512000 Then
      Folder = Server.MapPath("db") & "\" & ("Photos") & "\"
    
    FileName = Upload.UniqueName(Folder, FileName)
    
    Upload("File1").SaveAs Folder & FileName
    
    Set Upload = Nothing
    
    Response.Redirect ("gallery.html")
    end if
    end if 
    %>
    Those checks i got currently are just to limit the file size or checking for its ext, i need something more just to avoid pple from being able to upload fake files by just changing their ext from .txt to .jpg for example...

    Thanks in advance,
    Ulthane

  6. #6
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,631
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is the Lewis Moten uploader class you are using - yes? He mentions in his website a method to determine if the uploaded file is an image, and what type.

    Just search (Ctrl-F) in his site for Read Image Dimensions. In fact, I'd recommend you check out some of the other code snippets he has there.
    Ian Anderson
    www.siteguru.co.uk

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2010
    Location
    Israel
    Posts
    523
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    heh, i belive i deleted that asp file when i saw that i didnt use it, because i thought i wouldn't need to check for file deminsions, now i see how needed it is

    Thanks, working.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •