Sk   En  

Components of Px Framework:

PxUploader - component for uploading binary and text files to the server

The PxUploader component secures uploading of binary or text files from a client browser to the server. The PxUploader works with browsers like Windows Internet Explorer, Firefox, etc.. For the correct functioning of the PxUploader component you need to have the JavaScript enabled and the Flash Media Player installed in your web browser.

If you want to work with the PxUploader component, you have to define it in the *. aspx file as follows:

 <Prx:PxUploader ID="Uploader" runat="server" />

If you want the PxUploader component to be visible in the aspx files, define the "Prx" prefix related to the assembly of the PxUploader component in the header of the file. Do it as follows:

 <%@ Register TagPrefix="Prx" Namespace="PxUploader" Assembly="PxUploader" %>

Then you can work with the PxUploader component in the *. aspx.cs file as follows. First, use the UploadDir property to define in the PxUploader component the path to the directory where the files shall be stored.
Then enter to the IdUploadFile property the file Id which shall be attached to the file name as a prefix for the better unique file identification.
The MultiFiles property enables you to define whether one or several files can be selected for uploading to the server. More in the example below:

 Uploader.UploadDir = @"uploads\data";
 Uploader.IdUploadFile = 7777;
 Uploader.MultiFiles = false;

The FileDescription and FileExt properties enable you to control definition of the filter in the OpenDialog form, where the file selection according to the file extension is carried out.

 Uploader.FileDescription = "Image Files";
 Uploader.FileExt = "*.jpg;*.png;*.gif;*.bmp;*.jpeg;*.zip;*.rar";        

The SizeLimit property serves for definition of the maximum file size in bytes, which can be uploaded to the server. The PxUploader component allows to upload files up 2GB to the server. For more information please refer to the example below, which with the current pre-set allows to upload a file with the maximum size of 10 MB:

 Uploader.SizeLimit = 10485760;

The default file size that can be uploaded to the server, is set to 4MB in the IIS. This can be changed through the settings in the web.config file, under the <system.web> section in the maxRequestLength property. See the example below:

    <httpRuntime executionTimeout="110" maxRequestLength="2097151"
     requestLengthDiskThreshold="80" useFullyQualifiedRedirectUrl="false"
     minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="5000"
     enableKernelOutputCache="true" enableVersionHeader="true"
     requireRootedSaveAsPath="true" enable="true" shutdownTimeout="90"
     delayNotificationTimeout="5" waitChangeNotification="0"
     maxWaitChangeNotification="0" enableHeaderChecking="true"
     sendCacheControlHeader="true" apartmentThreading="false"/>

If you want to upload files of 2GB to the server, in the IIS version 7, set the maxAllowedContentLength property in the <system.webServer> section of the web.config file. Of course, it is necessary to remember to adjust the SizeLimit property and set the 2GB size there. More in the example below:

       <requestLimits maxAllowedContentLength="2097151000" />

The ButtonText property allows to change the name of the button of the PxUploader component. More in the example below:

 Uploader.ButtonText = "Add Files...";

The image of PxUploader component during the uploading of a file to the server looks like this, see picture below:

Obrázok PxUploader

The PxUploader component events:

The PxUploader component generates two events. These are the CompleteUpload and the AllCompleteUpload events. The CompleteUpload event is called in after the complete file uploading to the server directory, which was specified in the UploadDir property. The called in method body also contains the uploaded variables such as file name and file path where the file has been saved. The AllCompleteUpload event is called in after the CompleteUpload event, usually when all files have been uploaded to the server. Definition of individual events, and their linking to the methods shall be described, for more information please refer to the example below:

 protected void Page_Load(object sender, EventArgs e)
   Uploader.IdUploadFile = 7777;
   Uploader.UploadDir = @"uploads\data";
   Uploader.ButtonText = "Add Files...";
   Uploader.CompleteUpload += new
   Uploader.AllCompleteUpload += new

 void Uploader_AllCompleteUpload(object sender, EventArgs e)
   string a = "";

 void Uploader_CompleteUpload(object sender, string FileName, string Path, EventArgs e)
   string a = "";

Others articles of Px Framework:

It doesn't the intention of this part website, describe in detail the work with PxFramework components, a detailed description of the component available in manual, which can be downloaded here: Download manual of Px Framework