Pronunciation / adjective
Bringing something good and unforseen.
    Skip Navigation Links > Component Library > Image Upload Object
   

The Fortunate.ImageUpload object allows an image file to be uploaded to a website, resized, optimized, and converted to .jpg, .gif, or .png format.



 

View the Demo

Fortunate.ImageUpload Object

Download the Fortunate Library Here:

Fortunate Library 32bit - Stand-Alone Install

Fortunate Library 64bit - Stand-Alone Install

Fortunate Library Solution - Source Code

The Image Upload object allows a non-technical person to upload images to an asp.net website.

It allows an image to be uploaded, resized and optimized for the asp.net website without the need for any specialized graphics software.

Other features include the ability to convert an image to black & white and transparency in .gif or .png images.


Instructions for Using the Control

First place the control on your webpage. You should get a register assembly tag and a control tag:
  1. <%@ Register Assembly="ImageUpload" Namespace="Fortunate.Web" TagPrefix="cc1" %>
  2. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  3. <cc1:ImageUpload ID="ImageUpload1" runat="server" ImageSaveDirectory="~/images" TempImageDirectory="~/images/temp" Height="100%" width="75%" BorderStyle="Solid" BorderColor="Black" BorderWidth="2px" />
  4. <asp:HyperLink ID="ImageUploadedHyperLink" runat="server"></asp:HyperLink>
  5. </asp:Content>


Then create a directory to save your images in and a separate directory for working with temporary images. Set the image save and temp image directory locations in the control. I recommend setting them starting from root by using the tilde "~"

i.e.) if I wanted to save my images to a folder I created called images and use a temp directory called "temp" I created within that folder I would specify both like so:

Save Directory: "~/images"

Temp Directory: "~/images/temp"

The directories will need to have the proper permissions. There are instructions right within the control when the control is viewed in design mode within visual studio:
Image Upload Control Design Mode Screenshot

You'll also want to specify how long temporary images are kept before they are automatically deleted using the "TempImageDeleteTimeSpan" property. It is set to 1 minute by default. But I prefer to use 1 hour.

The final control entry should end up looking something like this:
  1. <cc1:ImageUpload ID="ImageUpload1" runat="server" ImageSaveDirectory="~/images" TempImageDirectory="~/images/temp" Height="100%" width="75%" BorderStyle="Solid" BorderColor="Black" BorderWidth="2px" TempImageDeleteTimeSpan="01:00:00"/>


You can also subscribe to an image uploaded event which sends some information about the uploaded image back to the page:
  1. Protected Sub ImageUpload1_ImageUploaded(ByVal e As Fortunate.Web.ImageUpload.ImageUploadedEventArgs) Handles ImageUpload1.ImageUploaded
  2. ImageUploadedHyperLink.Text = e.SavedImageAbsoluteUrl
  3. ImageUploadedHyperLink.NavigateUrl = e.SavedImageAbsoluteUrl
  4. End Sub
Microsoft Certified Professional   © 2017 Fortunate.  All rights reserved.
contact: justin@aboutfortunate.com