Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to manage uploading image files ?

Posted on 2009-02-20
3
Medium Priority
?
175 Views
Last Modified: 2013-11-07
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.
0
Comment
Question by:dimensionav
2 Comments
 
LVL 15

Accepted Solution

by:
aibusinesssolutions earned 2000 total points
ID: 23698695
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
 

Author Comment

by:dimensionav
ID: 23900242
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

572 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