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:
<%@ Register Assembly="ImageUpload" Namespace="Fortunate.Web" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<cc1:ImageUpload ID="ImageUpload1" runat="server" ImageSaveDirectory="~/images" TempImageDirectory="~/images/temp" Height="100%" width="75%" BorderStyle="Solid" BorderColor="Black" BorderWidth="2px" />
<asp:HyperLink ID="ImageUploadedHyperLink" runat="server"></asp:HyperLink>
</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:
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:
<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:
Protected Sub ImageUpload1_ImageUploaded(ByVal e As Fortunate.Web.ImageUpload.ImageUploadedEventArgs) Handles ImageUpload1.ImageUploaded
ImageUploadedHyperLink.Text = e.SavedImageAbsoluteUrl
ImageUploadedHyperLink.NavigateUrl = e.SavedImageAbsoluteUrl
End Sub
|