Validating DPI while upload

Posted on 2007-10-01
Last Modified: 2009-12-16
I need a system that allow user to upload images. However while the image is being uploaded, the system should check if the uploaded image is in the allowed DPI.

If I set acceptable DPI to 300, if user try to upload an image with 100 DPI it shouldn't accept.

Also I know usual way of validating file format is to check its file extension, however is there any better way to validate the file format? Maybe thru the pattern? Like illustrator have different set of pattern compare to coraldraw..
Question by:learningProcess
    LVL 58

    Accepted Solution

    In ASP no, in ASP.Net yes you can but you have to wait for the image to be fully uploaded first to be able to check it

    <%@ Page Language="c#"%>
    <%@ Import Namespace="System.Drawing.Imaging" %>
    <%@ Import Namespace="System.Drawing" %>
    <%@ Import Namespace="System.Drawing.Drawing2D" %>
    <script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
      Bitmap bmp= new Bitmap(Server.MapPath("your_image.jpg"));
      Graphics g=Graphics.FromImage(bmp);
      Response.Write (bmp.HorizontalResolution + " dpi");
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now