How to manage uploading image files ?

Posted on 2009-02-20
Last Modified: 2013-11-07

I need to develop an application that must accomplish the following:

1. Upload an image file to a website.
2. The image must accomplish special features like size, quality and defined maximum capacity in megabytes.
3. The application has to indentify if there is another file with the same name and extension.

How could I perform this?

Thanks in advance.
Question by:dimensionav
    LVL 15

    Accepted Solution

    Sure, that's easy enough.

        <form id="form1" runat="server">
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="Upload" />
        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
            If FileUpload1.HasFile Then
                'check to see that the file doesn't exist
                If Not IO.File.Exists(Server.MapPath("~/images/" & IO.Path.GetFileName(FileUpload1.PostedFile.FileName))) Then
                    Dim img As Drawing.Image = Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream)
                    Dim imgWidth As Integer = img.Width
                    Dim imgHeight As Integer = img.Height
                    Dim pixelFormat As Drawing.Imaging.PixelFormat = img.PixelFormat
                    Dim verticalRes As Single = img.VerticalResolution
                    Dim horizontalRes As Single = img.HorizontalResolution
                    Dim rawFormat As Drawing.Imaging.ImageFormat = img.RawFormat
                    Dim fileSize As Integer = FileUpload1.PostedFile.ContentLength
                    'do some stuff here if file is incorrect format, size, or dimensions
                    'do something here if the file exists
                End If
            End If
        End Sub

    Open in new window


    Author Comment

    I was on travelling and I need to try this out, please remain open this question for a couple of days more and I´ll give an answer soon.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now