I am receiving the following when I attempt to upload a file of any type:
The original file is in the temp folder. Full path of the file: C:\Temp\c449d8c7-0186-43a6-8d9f-9c92b33c00e6.tmp
I am setting it up as follows:
public enum UserType { LimitedUser, PowerUser, Admin };
protected void Page_Load(object sender, EventArgs e)
{
// Init for limited access Plant Users
UserType userType = UserType.LimitedUser;
// Setup User Authentication
using (UserAuth objPassPort = new UserAuth(HttpContext.Current))
{
if (objPassPort.IsUser)
{
userType = UserType.PowerUser;
}
// Override for Admins
if (objPassPort.IsAdmin)
{
userType = UserType.Admin;
}
}
// Setup Environment
FileVistaControl fileVistaControl = (FileVistaControl)LoadControl("filevista.ascx");
fileVistaControl.Style = "width: 100%; height: 100%;";
fileVistaControl.Fullscreen = true;
fileVistaControl.LicenseKey = "";
// Setup Directory and Permissions
FileVistaRootFolder rootFolder = createFolder("Plant Directory", @"C:\Inetpub\wwwroot\PDirectory\");
rootFolder.Permissions = setDirectoryPermissions(userType);
fileVistaControl.RootFolders.Add(rootFolder);
PlaceHolder1.Controls.Add(fileVistaControl);
}
private FileVistaRootFolder createFolder(string directoryName, string path)
{
FileVistaRootFolder rootFolder;
rootFolder = new FileVistaRootFolder(directoryName, @path);
return rootFolder;
}
private FileVistaPermissions setDirectoryPermissions(UserType userType)
{
// Init for limited access Plant Users
FileVistaPermissions objPermissions = FileVistaPermissions.ReadOnly;
switch (userType)
{
case UserType.Admin:
objPermissions = FileVistaPermissions.Full;
break;
case UserType.PowerUser:
objPermissions = FileVistaPermissions.Traverse |
FileVistaPermissions.List |
FileVistaPermissions.Download |
FileVistaPermissions.Compress |
FileVistaPermissions.Upload |
FileVistaPermissions.Rename |
FileVistaPermissions.Delete |
FileVistaPermissions.Extract |
FileVistaPermissions.Copy |
FileVistaPermissions.Paste |
FileVistaPermissions.Create;
break;
}
return objPermissions;
}
Daniel Penrod
3/10/2008 6:17 AM
I checked the files on the disk and they are all 112bytes with that same message in them. Word docs, txt docs, etc.
So something is going on with the upload that causes the files not to get written to disk correctly...
Any ideas?
Daniel Penrod
3/10/2008 8:44 AM
Upload module of FileVistaControl writes the uploaded files directly to the target folder and not to a temporary folder like c:\temp.
I guess ASP.NET's default upload mechanism uses that temporary folder so it seems, the module is not being fired for the uploads. Are you sure that you added the module related setting to web.config:
<httpModules>
<add name="UploadHttpModule" type="GleamTech.Web.FileTransfer.UploadHttpModule, GleamTech.Web.FileTransfer" />
</httpModules>
Cem Alacayir
3/10/2008 9:22 AM
Thanks for the reply. Yes I had the web.config file setup as mentioned.
The weird thing is that a file is appearing, so something got created. It is just the file itself is only 112 bytes with nothing but
The original file is in the temp folder. Full path of the file: C:\Temp\c449d8c7-0186-43a6-8d9f-9c92b33c00e6.tmp
in it.
Would it have anything to do with the fact that my application already uses an upload component called Element-IT.PowUpload. Cause in web.config I have it set to a temp path of:
tempPath = "C:\Temp\"
But you said it doesn't upload to a temporary place, so I doubt that's it.
I do notice that the file upload doesn't complete either. It gets hung up on something.
Is there anyway I can debug this? I guess I can't without the source.
Let me look in the event viewer to see if there are any signs of error.
Daniel Penrod
3/10/2008 9:54 AM
Ok no luck. Cannot seem to debug this to get a detailed error. All I can say is that the upload hangs for a second and then fails but says it is complete. The progress bar does not get to 100 percent but it does get to like 10 or 15 percent. All files are 112 bytes in length. I have tried various physical locations on disk with no luck. I tried adding full control for ASP.NET and it still did not work.
Testing it in IIS 5.1 Windows XP.
Daniel Penrod
3/10/2008 11:15 AM
Please remove any other upload modules from web.config.
A request is processed by each module that you put in web.config so the other module is interferring with GleamTech.Web.FileTransfer. Thus file upload in FileVistaControl is not completed.
After disabling the other module, you will see that the upload will start to work. If you must enable the other module in your application, see if it works by changing the order of <add /> lines in the <httpModules> section, i.e moving GleamTech.Web.FileTransfer to top in the list.
Cem Alacayir
3/10/2008 3:45 PM
Hey thanks! That was it. It works now. Ok, is there a way I can tap into your upload component and use it since I cannot use the other one now?
Do you have a simple C# example. Not needing anything complicated, just plain upload. But it needs to check for multiple FileUploads (if they exist) and upload them all to where I specify. So if I had 5 upload controls it would upload any or all files that were requested by the user.
Daniel Penrod
3/11/2008 4:45 AM
Nevermind, I just took the other component out and now I just use the standard .NET FileUploadControl way of doing it...
Thanks for helping me. I love the control! Very customizable and easy to extend and work with filevista.js
Daniel Penrod
3/11/2008 7:52 AM
I am glad you figured it out but I will still explain howto use our high-performance upload module in case you may want to use it instead of the standard .NET FileUploadControl.
I have sent you updated DLLs via email, the below information only applies to these version of the DLLs and not to the versions in v1.4.2, please update them and clean/rebuild your project.
After you add the module in <httpModules> section, the module will only handle the requests that have FT.Active=1 in the querystring. For instance, assume CustomUpload.aspx is the page in your application that you post your files to, then set the parameter FT.Active to 1 and FT.UploadID to a unique upload id in your post querystring:
<form action="CustomUpload.aspx?FT.Active=1&FT.UploadID=123" method="post" enctype="multipart/form-data">
<input type="file" name="file1" />
<input type="file" name="file2" />
<input type="submit" value="Upload" />
</form>
The upload module checks the parameter FT.Active to decide on taking the control of the current upload request. This allows you to expilictly activate the module for the specific pages and not the whole application. Note that the module should be added at the top in the <httpModules> section so that this mechanism works. Otherwise, another upload module will execute first and the upload request will not be processed by our module.
The module will write the temporary uploaded files to the App_Data subfolder of your application by default. If you want to change this location (eg. C:\Temp), add these lines to you web.config:
<configSections>
<sectionGroup name="system.web">
<section name="GleamTech.Web.FileTransfer" type="GleamTech.Web.FileTransfer.FileTransferSection, GleamTech.Web.FileTransfer"/>
</sectionGroup>
</configSections>
<system.web>
<GleamTech.Web.FileTransfer>
<uploadStorageProvider type="GleamTech.Web.FileTransfer.DefaultUploadStorageProvider, GleamTech.Web.FileTransfer" parameter="C:\Temp" />
</GleamTech.Web.FileTransfer>
</system.web>
Note that, you can also limit the maximum upload size (eg. 4000KB, default is 2GB) that the module will allow:
<system.web>
<GleamTech.Web.FileTransfer maxUploadSize="4000">
<uploadStorageProvider type="GleamTech.Web.FileTransfer.DefaultUploadStorageProvider, GleamTech.Web.FileTransfer" parameter="C:\Temp" />
</GleamTech.Web.FileTransfer>
</system.web>
In the code behind, you can save the uploaded files with this code:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string uploadID = Request.QueryString["FT.UploadID"];
UploadProgress uploadProgress = UploadProgress.GetUploadProgress(Context, uploadID);
if (uploadProgress.Status == UploadStatus.Completed)
{
foreach (UploadedFile uploadedFile in uploadProgress.UploadedFiles)
{
string tempFilePath = uploadedFile.ProviderData.ToString();
string newFilePath = Path.Combine(@"c:\SomeTargetFolder", uploadedFile.Name);
File.Move(tempFilePath, newFilePath);
}
}
}
}
Actually, we may release the upload module as a separate product in the future.
Cem Alacayir
3/11/2008 10:08 AM
Thanks so much!
Daniel Penrod
3/12/2008 5:14 AM