a me sembra che vada :master:
codice:
<%@ Page Trace="False" Language="vb" AspCompat="false" Debug="true" ValidateRequest="false" Strict="false" %>

<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Web" %>

<script language="VBScript" runat="server">

    Const Lx = 200
    Const Ly = 240
    Const upload_dir = "/tmp/"
    Const upload_original = "Ad_"
    Const upload_thumb = "_thumb"
    Const upload_max_size = 1500
    Dim fileExt
    Dim newWidth, newHeight As Integer
    Dim l2
    Dim fileFld As HttpPostedFile
    Dim originalimg As System.Drawing.Image
    Dim msg
    Dim upload_ok As Boolean
    Dim ad_id
    Dim picnumber
</script>


<%
    ad_id = Request.QueryString("ad_id")
    picnumber = Request.QueryString("picnumber")
    
    Randomize()
    upload_ok = False
    If LCase(Request.ServerVariables("REQUEST_METHOD")) = "post" Then
        fileFld = Request.Files(0) ' get the first file uploaded from the form (note:- you can use this to itterate through more than one image)
        If fileFld.ContentLength > upload_max_size * 1024 Then
            msg = "Attenzione, l'immagine deve essere max " & upload_max_size & "Mb"
        Else
            Try
                originalimg = System.Drawing.Image.FromStream(fileFld.InputStream)
                If (originalimg.Width / Lx) > (originalimg.Width / Ly) Then
                    l2 = originalimg.Width
                    newWidth = Lx
                    newHeight = originalimg.Height * (Lx / l2)
                    If newHeight > Ly Then
                        newWidth = newWidth * (Ly / newHeight)
                        newHeight = Ly
                    End If
                Else
                    l2 = originalimg.Height
                    newHeight = Ly
                    newWidth = originalimg.Width * (Ly / l2)
                    If newWidth > Lx Then
                        newHeight = newHeight * (Lx / newWidth)
                        newWidth = Lx
                    End If
                End If

                Dim thumb As New Bitmap(newWidth, newHeight)

                Dim gr_dest As Graphics = Graphics.FromImage(thumb)

                Dim sb = New SolidBrush(System.Drawing.Color.White)
                gr_dest.FillRectangle(sb, 0, 0, thumb.Width, thumb.Height)

                gr_dest.DrawImage(originalimg, 0, 0, thumb.Width, thumb.Height)

                Try
                    fileExt = System.IO.Path.GetExtension(fileFld.FileName).ToLower()
                    originalimg.Save(Server.MapPath(upload_dir & upload_original & ad_id & "_" & picnumber & fileExt), originalimg.RawFormat)
                    thumb.Save(Server.MapPath(upload_dir & upload_original & ad_id & "_" & picnumber & upload_thumb & fileExt), originalimg.RawFormat)
                    msg = "Uploaded " & fileFld.FileName & " to " & Server.MapPath(upload_dir & upload_original & fileExt)
                    upload_ok = True
                Catch
                    msg = "Sorry, there was a problem saving the image."
                End Try
                ' Housekeeping for the generated thumbnail
                If Not thumb Is Nothing Then
                    thumb.Dispose()
                    thumb = Nothing
                End If
            Catch
                msg = "Si è verificato un Errore. L'immagine non è stata elaborata."
            End Try
        End If

        ' House Keeping !
        If Not originalimg Is Nothing Then
            originalimg.Dispose()
            originalimg = Nothing
        End If

    End If
%>
<html>
<head>
    <title>ASP.NET File Upload and Resize Sample</title>
    <meta name="Description" content="ASP.NET File Upload and Resize Sample (Hybrid VB.NET)">
    <meta name="Keywords" content="ASP.NET, ASP, NET, VB, VBScript, Image, Upload, Resize, Thumbnail, Constrain, Filesize, File, Size, Free">
    <meta name="Copyright" content="Rufan-Redi Pty Ltd 2005">
    <meta name="Author" content="System developed by Jeremy at http://www.Rufan-Redi.com">
</head>
<body>
    


        Hybrid ASP.NET File Upload and Resize Sample (VB.NET)
        

        Upload and resize a GIP/JPG/PNG images, ensuring filesizes are optimum.</p>
    <form id="form1" enctype="multipart/form-data" method="post" runat="server">
    <table>
        <tr>
            <td>
                Select the file to upload:
            </td>
            <td>
                <input type="file" name="upload_file">
            </td>
        </tr>
        <tr>
            <td colspan="2">
                Max upload size
                <%=upload_max_size%>Kb, gif/jpg/png only
            </td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="Upload">
            </td>
        </tr>
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server" Text="" EnableViewState="false"></asp:Label>
                

                <asp:Label ID="Label2" runat="server" Text="" EnableViewState="false"></asp:Label>
            </td>
        </tr>
    </table>
    </form>
    <%
        If upload_ok Then
    %>
    <table>
        <tr>
            <td valign="top">
                [img]<%=upload_dir & upload_original & ad_id & [/img]">
            </td>
            <td valign="top">
                [img]<%=upload_dir & upload_original & ad_id & [/img]">
            </td>
        </tr>
    </table>
    <%
    Else
        Response.Write(msg)
    End If
    %>
</body>
</html>