How to manage uploading image files ?

HI

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.
dimensionavAsked:
Who is Participating?
 
aibusinesssolutionsCommented:
Sure, that's easy enough.

default.aspx
<body>
    <form id="form1" runat="server">
    <asp:FileUpload ID="FileUpload1" runat="server" />
    <asp:Button ID="Button1" runat="server" Text="Upload" />
    </form>
</body>
 
default.aspx.vb
    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
 
            Else
                'do something here if the file exists
 
            End If
        End If
    End Sub

Open in new window

0
 
dimensionavAuthor Commented:
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.

thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.