hello,
i have this vb code to upload images it works fine but i am stuck with 2 functions
1. before uploading image it should check the size of image if it is greater than 2 mb it should show error "max size allowed 2 mb"
2, and if width is greater than 800 it should resize the image widht to 800px than upload please advice
If Request.Files.Count > 0 Then
If LCase(Request.Files(0).FileName).EndsWith(".jpg") Then
If Request.Files(0).ContentLength > 0 Then
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("rcon").ConnectionString)
Dim cmd As New SqlCommand("Insert into AwningSim (OrigImage) OUTPUT Inserted.guid VALUES (@OrigImage)", con)
Dim b(Request.Files(0).ContentLength) As Byte
Request.Files(0).InputStream.Read(b, 0, Request.Files(0).ContentLength)
cmd.Parameters.AddWithValue("OrigImage", b)
con.Open()
Dim g As Guid = cmd.ExecuteScalar()
con.Close()
Response.Redirect("Adjust.aspx?leadid=" & Request("leadid") & "&ID=" & g.ToString)
Else
'ERROR: Error uploading the file. Empty or corrupt?? This should be a rare occurence...
End If
Else
<form id="Form1" runat="server">
<input type="hidden" name="leadID" value="<%=Request("leadid")%>">
<input type="hidden" name="home" value="<%=Request("home")%>"/>
<p class="showIE" style="display:none;">
<input id="File1" runat="server" type="file" class="uploadinput"/><br /><br />
<asp:Button ID="btnSubmit" CssClass="submit" runat="server" Text="Submit" />
</p>
<asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label>
</form>