Quick Developer Tutorial

The following lessons will show you from start to finish how to utilize the Mediachase FileUploader.NET.

Please follow the steps within each tutorial lesson to learn more and to get acquainted with how to use the Mediachase FileUploader.NET. Let’s get started. 

Lesson 2 - Uploading new files to file storage

[Go to Online sample] [Download source]

1. Start

We start with the .aspx page which shows files located in some folder (fig. 1). To add Mediachase FileUploader.NET on this page we should make the following actions.

 

Fig. 1

 

2. Add reference to Mediachase.FileUploader.dll (fig.2).

Fig.2

 

3. Add the following files to your project: uploadembedded.aspx, uploadiframe.aspx, uploadpopup.aspx (fig.3).

Fig. 3

4. Add the following code to your project web.config file:

<configSections>

<sectionGroup name="mediachase.fileUploader" type="Mediachase.FileUploader.Configuration.MediachaseFileUploaderSectionGroup, Mediachase.FileUploader">

<section name="fileUploaderContext" type="Mediachase.FileUploader.Configuration.FileUploaderContextSection, Mediachase.FileUploader"/>

<section name="tempFileStorage" type="Mediachase.FileUploader.Web.Configuration.TempFileStorageSection, Mediachase.FileUploader"/>

<section name="uploadProgress" type="Mediachase.FileUploader.Web.Configuration.UploadProgressSection, Mediachase.FileUploader"/>

<section name="fileUploadControl" type="Mediachase.FileUploader.Web.Configuration.FileUploadControlSection, Mediachase.FileUploader"/>

</sectionGroup>

</configSections>

<mediachase.fileUploader>

<fileUploaderContext/>

<tempFileStorage timeout="60">

       <providers>

                    <add name="McLocalDiskTempFileStorageProvider" type="Mediachase.FileUploader.Web.LocalDiskTempFileStorageProvider, Mediachase.FileUploader" description="" tempStoragePath="%TEMP%" />

             </providers>

       </tempFileStorage>

       <uploadProgress timeout="60">

             <providers>

                    <add name="McInProcessProgressStateProvider" type="Mediachase.FileUploader.Web.InProcessUploadProgressProvider, Mediachase.FileUploader" description="" />

             </providers>

       </uploadProgress>

</mediachase.fileUploader>

 

Add the following string to <httpModules> section:

<add name="Mediachase.FileUploader.McHttpModule" type="Mediachase.FileUploader.McHttpModule, Mediachase.FileUploader"/>

Add the following string to <httpHandlers> section:

<add verb="GET" path="McFileUploaderResources.axd" type="Mediachase.FileUploader.AssemblyResourceHandler, Mediachase.FileUploader" />

 

5. Add FileUploader controls to VisualStudio Toolbox clicking “Browse” button and selecting “Mediachase.FileUploader.dll” (fig.4-7):

 

Fig. 4

 

Fig. 5

Fig. 6

 

Fig.7

 

6. Now you can drag “FileUploadControl”, “FileUploadProgress”, “FileUploadActions” and “UploadedFileList” from VisualStudio 2005 Toolbox and drop on the page in design mode. Then you can set controls’ properties in “Properties” window (fig.8).

Fig.8

 

7. “FileUploader” control will appear on your page (figures 9-12).

Fig. 9 FileUploader in its default view.

 

Fig. 10 FileUploader in expanded view.

 

Fig. 11 FileUploader (FileUploadProgress) during file uploading.

 

Fig. 12 FileUploader (UploadedFileList) with three uploaded files in temporary storage

8. To save uploaded files in the folder you can use the following code (C#):

FileStreamInfo[] fsi = fuControl.Files;

if (fsi != null)

       for (int i = 0; i < fsi.Length; i++)

       {

             fuControl.SaveAs(fsi[i], Path.Combine(LocalPath, Path.GetFileName(fsi[i].FileName)));

       }

}

fuControl.ReleaseAll();

Copyright 2007 Mediachase. All rights reserved.