.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Resize Images on upload

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :Windows Application

Hi All,

I'm developing a web site using VWD 2005 Express which allows users to upload images using the file upload control. Easy enough but I want to resize the uploaded images to ensure large file sizes are not saved and to reduce the picture sizes to no more than 300x200 pixels before I save them to disk. I've seen some code examples, mainly C#,  but nothing that clearly explains how to do this and nothing using VB code, which is my preference.  I'm looking for some code/pointers and ideas on how to achieve this. Can anyone help me out please?



View Complete Post

More Related Resource Links

ASP.NET HTML Editor - Upload images

The article ASP.NET HTML Editor - Upload images was added by adarshtated on Tuesday, June 29, 2010.

In this article we are seen how to create a custom HTML Editor control to add image button in it.Create A Class-----------CustomEditor.cs------------------Add Name Spaceusing AjaxControlToolkit.HTMLEditor;namespace MyControls{ public class CustomEditor

Need to upload images with data, but image url's are in separate db table

Hello, I'm making a simple homes classifieds section and when a home ad is created, a HomeID is automatically created for it in the db.  I need the images to upload and enter the associated HomeID with each image automatically.  What I tried isn't working, because it looks like it's looking for the HomeID in the codebehind before it gets entered into the db.ASPX CODE<asp:SqlDataSource ID="SqlDataSource1" runat="server"         ConnectionString="<%$ ConnectionStrings:ConnectionString %>"         InsertCommand="INSERT INTO [Homes] ([UserName], [Street], [Details], [Contact], [Phone], , [Thumb], [Price], [Approved], [Posted]) VALUES (@UserName, @Street, @Details, @Contact, @Phone, @Email, @Thumb, @Price, @Approved, @Posted)"         SelectCommand="SELECT [HomeID], [UserName], [Street], [Details], [Contact], [Phone], , [Thumb], [Price], [Approved], [Posted] FROM [Homes]" >        <InsertParameters>            <asp:Parameter Name="UserName" Type="String" />            <asp:Parameter Name="Street" Type="Str

upload images to a picture library from infopath form



   I am having an infopath form, from where i need to upload images to picture library . 

Multiple Images upload to SQL Database C# code help pls !



I have a web form where user can upload image and store to SQL database. (SQL tables has a relation like one title has multiple images fields).

Title: <asp:TextBox ID="txtTitle" runat="server" Width="300px"></asp:TextBox>

Image Name:<asp:TextBox ID="txtImage" runat="server" Width="200px"></asp:TextBox>

<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnSubmit" runat="server" Text="Submit Information" 
               onclick="btnSubmit_Click" />

aspx.cs code:

 protected void btnSubmit_Click(object sender, EventArgs e)
//to store image into sql database.
         string strImageName = txtImage.Text.ToString();      

                    if (FileUpload1.PostedFile != null &&
                    FileUpload1.PostedFile.FileName != "")
                           byte[] imageSize = new byte[FileUpload1.PostedFile.ContentLength];

I want to upload images in to a folder in my project and save the URL in the database.


Hi, I want to upload images in to a folder in my project and save the URL in the database.

When you add a record into my database you provide title, date added and some other details and there it a file upload control which you browser to a image and it saves the image to a folder in my project, it all works, the record is added and the image is uploaded into the folder, but the problem I have is that there is no link from the record to the image, there is no URL path saved in the record. How do I save the image in the folder and save the URL of the image to the record?

I'm using details view to insert the records and using grid view to view the records.



DetailsView Image Resize on Upload


I am using a details view to add a name and image path to a database. I have a template with a fileupload control and a dropdown list (landscape and portrait), that is used to get the file name. My question is: How can I resize the image based upon whether the image is landscape or portrait? This is my code so far:

<%@ Page Title="" Language="VB" MasterPageFile="~/Admin.master" AutoEventWireup="false" CodeFile="UploadGallery.aspx.vb" Inherits="Admin_UploadGallery" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<h1>NTTC Administration: Upload Pictures to Gallery</h1>
    <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="318px" 
        AutoGenerateRows="False" DataKeyNames="ID" DataSourceID="SqlDataSource1" 
        DefaultMode="Insert" GridLines="None">
            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
                ReadOnly="True" Sor

how to auto resize image then upload ?


how to auto resize image then upload??

any1 can help me?


below is my code:

 If FileUpload1.HasFile Then
                filename1 = FileUpload1.FileName
                savePath1 += filename1

                sSQL1 = "SELECT * from news order by PicID desc"
                conn1 = New SqlConnection(ConnStr)
                cmd1 = New SqlCommand(sSQL1, conn1)
                rd1 = cmd1.ExecuteReader()
                Dim n As Integer
                n = rd1.Item("PicID") + 1
                sSQL = "select * from news"
                conn = New SqlConnection(ConnStr)
                cmd = New SqlCommand(sSQL, conn)
                da = New SqlDataAdapter(cmd)
                cb = New SqlCommandBuilder(da)
                ds = New DataSet
                da.Fill(ds, "news")

                nrow = ds.Tables("news").NewRow()
                nrow("PicID") = n
                nrow("ImagePath") = "~/new/news_images/" + filename1
                nrow("Tittle") = tittle
                da.Update(ds, "news")

                FileUpload1.SaveAs(Server.MapPath("/new/news_images/" & filename1))
                lblmsg1.Text = "Image Upload Successful!"

Upload Multiple File using JQuery in asp.net

In this article I have explained how to upload multiple files using file upload control. I have used jQuery plugin for uploading multiple files.

I have also explained how to check for file type, file maximum size limit using jQuery & also using server side validation code.

Upload a File to a SharePoint Document Library - Part I

The following helper class demonstrates a few techniques that allow documents to be uploaded to a SharePoint document library programmatically without using the API or a custom web service. You don't need to specify a document library name, and it will create any folders specified in the URL as required. File meta data will be updated if any properties are passed.

Images in WPF

How to create a Thumbnail of an Image. How to automatically crop an image. The following method allows you to automatically crop an image to it's content.

Multi File Upload Using JQuery!

Everyone knows about the file upload in .NET. But the multi file upload is some what difficult in .NET. For that purpose we can have some AJAX or JQuery!. Jquery is the latest advanced version. It will give some animated upload. You can try it for your own!!!!

Reading and Writing Images From a Windows Mobile Database using UltraLite 10(C#)

Periodically I get a request for information on how to read and write binary data to a database running on Windows Mobile. If you search the Internet you can typically find examples that are available on Windows Desktops or allow you to read and write to a local file system. The problem is that it can take a bit of work to get this code to work on Windows Mobile accessing a database.

Ultimately you might be asking, why would I want to store and image in a database? Well in an environment where you synchronizing data between a local mobile database and a consolidated (central) database this can be extremely useful. Imagine if an insurance adjuster went to an accident scene, took a picture of a damaged car, loaded it into his Windows Mobile database and then replicated that image up to the Insurance headquarters for approval. All of this could be done in a very short period of time when using images in the database. Another good example might be a doctor who was waiting for a patient chart to become available. If you could store the image in a database this chart could be sent down to the doctor's device once it became available.

For this article I am not going to get into how to synchronize the images to and from a remote and central database as this is typically fairly straightforward when using a data synchronization technologies like MobiLink

Save images to SQL CE

Storing binary objects (such as image, office document etc.) into database is a little cumbersome when it comes to retrieval. Hence the most commonly accepted way is only store the file path in the database, and to store the documents on a file share.

Store and Display Images from MS Access Database Using C#

There is only the difference of coding syntax to stream the binary data of image content type to upload it into MS Access Database using C#/VB in ASP.Net 2.0

Namespaces required:-
using System.Data.OleDb;

OleDb is used to connect the web site forms with MS Access Database using Microsoft.Jet.OLEDB.4.0

ASP.Net Upload Image to MS Access Database

As you learnt from the previous articles to upload image to the SQL Database in ASP.Net 2.0 and stream that image into the memory to retrieve it from the database and display it on the web page. In this article you will learn how to upload images to the MS Access database in ASP.Net 2.0

First of all create an Access Database and place it in the App_Data folder of ASP.Net web site project. Then create a table "tblImg" with the following fields:

Open File Print File Excel

Batch print many Excel files without having to open each one at a time. Quickly print mass amounts of xls files at once with this program. You must have Excel installed on your machine..

The Free Barcode Creator produces barcode images one at a time, and allows easy saving to a file or

The Free Barcode Creator produces barcode images one at a time, and allows easy saving to a file or pasting into an application. 2D versions are also available:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend