Mediachase FileUploader.Net FAQ

Q: Sometime, If I had turned-on Application-level tracing, the file uploader didn't optimize incoming request

Q: Has anyone been able to use the multi-upload code given as an example in the documentation on a Macintosh?

Q: I received an empty file

Q: How to Interference with System.Web.UI.HtmlControls.HtmlInputFile

Q: Couldn't upload a file that is about 1MB.

Q: How to limit maximal and minimal upload file sizes

Q: How to abort an upload operation if the file size exceeds the maximal allowed one

Q: A progress bar in a sample is not rendered

Q: How a file type can be validated before the upload process takes place?

Q: How to get rid of 'Access to path denied' error when uploading the fie

Q: How to obtain a name of the file that is currently being uploaded

Q: How to determine the size of the uploading file before it has been uploaded to the server?

Q: How to determine which integration mode to use?

Q: What is the best/recommended location for this temporary folder?

Q: How to upload the file directly to an ADO.NET Table?

Q: How many simultaneous uploads a single server can handle?

Q: How to optimize uploading process on a high speed network?

Q: Where can I find a more information about Mediachase FileUploader.Net control?


Q: Sometime, If I had turned-on Application-level tracing, the file uploader didn't optimize incoming request

A: Yes we've found that sometime Application-level tracing can disable Mediachase FileUploader.Net. For example, if you restart ASP.NET and try to upload large file as first request, sometime you will receive a page error. We recommend to disable Application-level tracing: Open web.config, find trace  element and set enabled attribute to false.

Q: Has anyone been able to use the multi-upload code given as an example in the documentation on a Macintosh?

A: Hot Fix (Release 1.9 and later have included it):

1. Open *.aspx (*.ascx) file.  

2. Find McHtmlInputFile control and wrap it in DIV, like 

Old Code: 
---------------------
<cc1:McHtmlInputFile id="McFileUp" runat="server" onchange="NextFile()"></cc1:McHtmlInputFile>
--------------------- 

New Code:
---------------------
<DIV>
<cc1:McHtmlInputFile id="McFileUp" runat="server" onchange="NextFile()"></cc1:McHtmlInputFile>
</DIV>
--------------------- 

3. Change NextFile function

New Code:
---------------------
function NextFile()
{
var coll = document.getElementsByName("McFileUp");
var LatestFile = coll[coll.length - 1];
var objBr = document.createElement("BR");

LatestFile.parentNode.appendChild(objBr);

var objFile = document.createElement("input");
objFile.type="file";
objFile.name="McFileUp";
objFile.onchange=NextFile;
LatestFile.parentNode.appendChild(objFile);
}
---------------------

4. Run web app.

Q: I received an empty file

A: The Enctype property of an HtmlForm must be set to " multipart/form-data" for this control to work properly.

Q: How to Interference with System.Web.UI.HtmlControls.HtmlInputFile

A: Look, Step by step:

1. If you use a FileUploder.NET in Full Mode, the FileUploder.NET control replaces a Real File from the memory with the Active Marker and saves file into the Temp folder.

2. The FileUploder.NET control recognizes the Active Marker, contrast with HtmlInputFile that sees the Active Marker as File Data.

To solve problems like your problem:

- We have implemented that the McHttpPostedFile can be created from the HttpPostedFile source.

- We have implemented page filters

So, you can:

  • use McHttpPostedFile to convert the Active Marker to File Data from HttpPostedFile.
  • use page filters to optimize incoming files from page A and doesn’t optimize from page B.

Q: Couldn't upload a file that is about 1MB.

A: The information in this thread applies to:

- Mediachase.FileUploader

- ASP .NET 1.1

SYMPTOMS

You added BufferSize attribute to httpPost node in your web.config file, then

when you used Mediachase.FileUploader + ASP .NET 1.1 you got an error, like these:

- The page cannot be displayed

- Server Application Unavailable

and so on.

PROBLEM

For ASP .NET 1.1 + Mediachase.FileUploader, you couldn't set BufferSize's value greater then 1000000.

RESOLUTION

Modify web.config: either Removed BufferSize attribute or set value less or equal then 1000000.

Q: How to limit maximal and minimal upload file sizes

A: It can be done via:

  1. Web.config file.

Open section <Mediachase.FileUploader.McHttpModule>
and add an attribute that represents the minimal POST(FILE) request size in kilobytes. into either httpFile or httpPost node.

If user tries to upload a post (file) bigger than you allow he will receive exception.

Example:


<httpFile MinSize="YOUR:VALUE" MaxSize="YOUR:VALUE" />

<httpPost MinSize="YOUR:VALUE" MaxSize="YOUR:VALUE" />

  1. User code action

Get submit event and validate file size.

P.S. The Main problem (to implement the Normal File Size Validation and Chancel operation) is a HttpModule can't either redirect or render output html until all incoming data has received.


Q: How to abort an upload operation if the file size exceeds the maximal allowed one

A: Only two ways:

1. Close connection via throw Exception, user will receive the error likes: Server closed connection.

2. Read all incoming data and then redirect user.

The HTTP protocol (and ASP.NET) doesn't allow sending response till it has received all incoming data.

Q: A progress bar in a sample is not rendered

A:  Open Progress.aspx page:


Find the lines like bellow


<table>

<tr style="height:18px;">
<td class= "ms-vb"style="background-color:#000099;width:<%=PercentsAbs %>;"></td>
<td class="ms-vb" style="background-color:White;width:60%;"></td>
</tr>

</table>


And check your background-color attributes. First line is progress line (Blue color), second – (White).

When you have opened ASPX(ASCX) file to design it The Visual Studio's editor likes change it, very much (be careful).


Q: How a file type can be validated before the upload process takes place?

A: Use ASP.NET Client Side Validators.


Example (Just open your either .aspx or .ascx page and assign regularexpressionvalidator to your FileUp control):


<asp:regularexpressionvalidator id="RegularExpressionValidator2" runat="server" ErrorMessage="Wrong Format" ControlToValidate="FileUp" ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))+(.zip|.ZIP|.Zip|.ZiP|.zIP|.ziP)$"></asp:regularexpressionvalidator>


Q: How to get rid of 'Access to path denied' error when uploading the fie

A: Check httpFile section, the path should have an allow permission to write. Or add the following line instead:


<httpFile TempStoragePath="%TEMP%" />
<!-- use User default TEMP folder -->


Also your should check which account use ASP.NET to launch pages.

MSDN Article: "An Introductory Guide to Building and Deploying More Secure Sites with ASP.NET and IIS"


Q: How to obtain a name of the file that is currently being uploaded

A: Step 1. Get Form info object


public static Mediachase.FileUploader.FormInfo McFormProgress.GetFormInfo(string MediachaseFormID)


Step 2. Get current file name

FormInfo.CurrentFileName


Q: How to determine the size of the uploading file before it has been uploaded to the server?

A: Use Client-side script.

Example (Java Script): 

function GetFileSize(filePath)
{
var fso, f, s;
fso = new ActiveXObject("Scripting.FileSystemObject");
f = fso.GetFile(filePath);
s = f.Size ;
return(s);
}


Q: How to determine which integration mode to use?

A: Different integration modes allow you to integrate 'Step by Step' FileUploader Control into your existed Application.

  • Simple – http-module is disabled, Mediachase.FileUploader.Web.UI.McHtmlFileInput control elements are used
  • Medium - http-module is activated, Mediachase.FileUploader.Web.UI.McHtmlFileInput control elements are used, large file optimization is not used
  • Full - http-module is activated, Mediachase.FileUploader.Web.UI.McHtmlFileInput control elements are used, large file optimization is used


Q: What is the best/recommended location for this temporary folder?

A: You can use the ASP.NET User Temporary Folder: "c:\Documents and Settings\ASPNET\Local Settings\Temp" or just “%TEMP%”.


Q: How to upload the file directly to an ADO.NET Table?

A: Please read How to by Microsoft: HOW TO: Read and Write a File to and from a BLOB Column by Using Chunking in ADO.NET and Visual C# .NET


Q: How many simultaneous uploads a single server can handle?

A: You can upload as many files as support IIS and ASP.NET server configuration. You know, IIS and ASP .NET has limited open connections at any one time.


Q: How to optimize uploading process on a high speed network?

A: You can try to change the Temp Buffer size. It has a default value of 64kb. For local networks or high speed interconnects you can use a larger value like a 20Mg temp buffer as an example.

If you want to change your Temp Buffer size:


1. Open Web.config for your project

2. Find or add Mediachase.FileUploader.McHttpModule section.

3. Find or add httpPost node, and change attribute BufferSize.

<httpPost BufferSize=”10485760” />

Ex: //10485760 bytes == 10Mg


P.S. 64kb is good value for Internet @ approximately 15-20 Kbit per sec


Q: Where can I find a more information about Mediachase FileUploader.Net control?

A: Please visit Mediachase FileUploader.Net Forum http://www.mediachase.com/forums/ShowForum.aspx?ForumID=18


Copyright 2005 Mediachase. All rights reserved.