I've some problem using RadAsyncUpload [Q2 2010 .Net 3.5].
When I want to save uploaded file to the specified folder, sometime it raised error exception: cannot find [temporary file location]. You can see error message on the pic attached.
This problem doesn't always occur, means sometime I can successfully save the file.
Below is my code when for saving the file:
If
RadAsyncUpload1.UploadedFiles.Count > 0
Then
For
Each
validFile
As
UploadedFile
In
RadAsyncUpload1.UploadedFiles
Dim
targetFolder
As
String
= Server.MapPath(
"~/uploadedFile/"
)
If
Not
Directory.Exists(targetFolder) =
True
Then
Directory.CreateDirectory(targetFolder)
End
If
validFile.SaveAs(Path.Combine(targetFolder, validFile.FileName),
True
)
Next
End
If
Thank you..
23 Answers, 1 is accepted
I reviewed the screenshot. Could you please check the temporary folder for the mentioned file when the exception is thrown.
When a file is uploaded by the RadAsyncUpload control it is placed in a temporary folder. After a certain time (by default 4 hours) the files from the temporary folder are deleted by the asp.net framework. If the TemporaryFileExpiration property is set the expiration time will be different and it is possible the files to be deleted before your logic after the postback is applied and that should be causing the sporadic throwing of exceptions.
Regards,
Peter Filipov
the Telerik team
I monitored the temporary folder, and it seems the temporary files wasn't created when the exception occur. Is it possible RadAsyncUpload not create the temporary file because I put it on <asp:updatePanel> tag? Or should I set the expiration time using TemporaryFileExpiration property? Since currently I didn't set it..
FYI, you could find my current application structure below. Maybe it could help to solve the problem:
Master Page:
<
MasterPage
>
<
asp:UpdatePanel
>
<
asp:ContentPlaceHolder
ID
=
"MainContentPlaceHolder"
runat
=
"server"
>
[Form1.aspx]
</
asp:ContentPlaceHolder
>
</
asp:Updatepanel
>
</
MasterPage
>
Form1.aspx:
<
asp:Content
ID
=
"ca_form"
ContentPlaceHolderID
=
"MainContentPlaceHolder"
runat
=
"Server"
>
[UserControl1.ascx]
[UserControl2.ascx]
[Attachment.ascx]
</
asp:Content
>
Attachment.ascx:
<
div
class
=
"attachment"
>
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
>
</
telerik:RadAsyncUpload
>
</
div
>
I setup a sample project from the provided structure and everything works fine at my side. Could please confirm that you found a pattern to reproduce the issue. If yes, please send me your project to test it locally.
Regards,
Peter Filipov
the Telerik team
After some testing, I found some pattern when the error occur:
1. When I'm debugging
2. When the page do postback, before the file to be attached was selected.
In few days, I'll send you my project so you could test it locally.
Thank you for your assistance :)
I'm having the same problem, cannot find the temporal file but only with IE8 Browser, everything it's working fine with Chrome, Firefox, etc.
The only one that is not creating the temporal file is IE8, I'm using the last controls that comes with Sitefinity 5.0.
Regards.
We still can not reproduce the issue at our side and we are waiting for Edwin's sample.
@Angel If you have a pattern to reproduce the issue try to set DisablePlugins property to true and test your project. Also if it is suitable for you please send me an example that reproduces the issue.
All the best,
Peter Filipov
the Telerik team
I apologise for the delay, little bit busy this 2 weeks..
err.. how could i attach my sample project? Its size is 6MB after being zipped x___x
hehe.. thank you
I just found an abnormality when I upload file using RadAsyncUpload.
The case is the temporary file is automatically gone after few second (maybe about ten seconds), and it always happened.
Maybe this is the root cause of my problem??
below is my code for the attachment page:
<
telerik:RadAsyncUpload
ID
=
"RadAsyncUpload1"
runat
=
"server"
TemporaryFileExpiration
=
"00:30:00"
OverwriteExistingFiles
=
"true"
AllowedFileExtensions
=
"pdf"
MaxFileSize
=
"500000"
>
</
telerik:RadAsyncUpload
>
The problem is related to the version that you are using, i.e. it is fixed for later version. Please either follow the workaround explained in this sticky thread (the Q2 2010 (Version 2011.2.713) section) or upgrade to a newer version of AJAX suite.
Kind regards,
Genady Sergeev
the Telerik team
I've updated my telerik version and right now the problem has been solved.
Thank's for your support :)
Kind Regards,
Edwin K
We have the same issue as "Edwin" , and we are using the last Build of Telerik UI (2012.1.201.40).
Please help us, we are trying to upload a file on our webform (ASP.NET 4).
Than when we are trying to file.SaveAs(path...) we are getting this error.
Its appears all the time, constantly.
This is the code:
<telerik:RadAsyncUpload ID="rdUploadedDocs" enablefileinputskinning="True"
runat="server" MaxFileInputsCount="3" AllowedFileExtensions=".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.jpeg,.jpg,.tif,.gif"
TargetFolder="~/Files/" TemporaryFolder="~/Temp_Files" OnClientValidationFailed="validationFailed"
ControlObjectsVisibility="RemoveButtons,AddButton" MaxFileSize="1500000" />
Thanks,
You can try to get the file by using this code:
protected
void
RadAsyncUpload1_FileUploaded(
object
sender, FileUploadedEventArgs e)
{
string
targetFolder = RadAsyncUpload1.TargetFolder;
Response.Write(Server.MapPath(targetFolder +
"/"
+ e.File.FileName));
}
Hope this will be helpful.
Regards, Plamen
the Telerik team
But, i would like to recheck in the server side if file exists in temporary folder before saving it.
Is it possible to add checking in Uploadedfilescollection. How do we access full path of temporary file here?
foreach (UploadedFile NewFile in AsyncUpload1.UploadedFiles)
{
string strPath = Server.MapPath(AsyncUpload1.TemporaryFolder);
FileInfo file = new FileInfo(strPath + "\ + NewFile.FileName);
if(File.Exists(file))
{
\\ This doesn't work,. Gives me the uploaded file name not the temp file name. But, i could see it in input stream and not able to access it.
}
Please help.
File will be removed from the temporary folder if:
- you use FileSave() method.
- it expires. The default expire time is 4 hours and it can be increased.
- the Application pool is recycled.
Here is how you can check whether the file exists:
Handler.ashx
<%@ WebHandler Language=
"C#"
Class=
"Handler"
%>
using
System;
using
System.Web;
using
Telerik.Web.UI;
using
System.Data;
using
System.Drawing;
using
System.Drawing.Imaging;
using
System.Data.SqlClient;
using
System.IO;
public
class
Handler : AsyncUploadHandler, System.Web.SessionState.IRequiresSessionState
{
protected
override
IAsyncUploadResult Process(UploadedFile file, HttpContext context, IAsyncUploadConfiguration configuration,
string
tempFileName)
{
if
(file !=
null
)
{
}
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
1. I used File.save as method both in FileUploaded method and Submit button postback which caused it.
So, I am saving to target folder from submit click and not using uploaded event anymore. This is because I need to do some steps before saving files to target folder.
2. Default expiration doesnot work in ie 8 and I have fixed it by setting this property.
3. I tried your method to check if file exists but its called only in client side upload not after postback.
I am trying to recheck these files incase there is a app pool recycle happened or any other file issue before proceeding to save to target folder.
I tried below, but, it caused error file used by another process later when file is saved to target folder.
foreach (UploadedFile file in AsyncUpload1.UploadedFiles)
{
try
{
using (Stream stream = file.InputStream)
{
byte[] imageData = new byte[stream.Length];
stream.Read(imageData, 0, (int)stream.Length);
if (imageData.Length == 0)
{
isFileAvailable = false;
}
}
}
catch
{
isFileAvailable = false;
}
finally
{
file.InputStream.Close();
file.InputStream.Dispose();
}
if (!(isFileAvailable))
{
RadAjaxManager1.Alert("Please upload the images again.");
return;
}
}
Is there a better way to do this check?
​
It doesn't matter what browser you use. The default File Expiration time is 4 hours. It uses the Application Cache (in IIS), not the browser.
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Try This.
foreach(UploadedFile file in rauUploadFiles.UploadedFiles)
{
FileStream tmpFile = (FileStream) file.InputStream;
List<String> currentImages = Directory.GetFiles(HttpContext.Current.Server.MapPath("~/temp")).Where(f => f.Equals(tmpFile.Name)).ToList();
}
Radasyncupload temporary files are deleted prior to Temporary File Expiration value ( The value is 1 hour)
Issue one-the temporary file expiration time does not work as expected:
-temporary file get deleted from server after 5 minutes if this setting is set to 5 minutes(expected);
-temporary file get deleted from server after 20 minutes if this setting is set to 20 minutes(expected);
-temporary file get deleted from server around 30 minutes if this setting is set to 1 hour or 4 hours.
Issue two-multiple temporary files get deleted at one time around 30 or 40 minutes even their uploaded time are different.
Example: a. set the expiration time to 20 minutes.
b. user1 uploaded file1 at 11:00AM,
c. user2 uploaded file2 at 11:05AM,
d. user1 saved file1 at 11:10Am and uploaded another file3 at 11:12AM
e. the expiration time for file2 should be 11:25PM and file3 should be 11:32PM base on the setting in step a. But actually, all files are removed around 11:21AM.
Issue is all files get removed at same time not base on their uploaded time. this is not expected and that means multiple user upload multiple files will have problem for sure.
<telerik:RadAsyncUpload RenderMode="Auto"
runat="server"
AllowedFileExtensions="jpg,jpeg,png,gif,doc,docx,mp3,mp4,mpeg,mov,avi,txt,csv,xlsx,xls,pdf,wmv,mkv,mpg,zip"
MaxFileSize="2147483647"
ID="AsyncUpload1"
TemporaryFileExpiration="01:00:00"
MaxFileInputsCount="1"
OnClientFileUploaded="onClientFileUploading1"
OnClientFileUploadRemoved="onClientFileRemove1"
OnClientValidationFailed="validationFailed">
<FileFilters>
<telerik:FileFilter Description="Media Files" Extensions="jpg,jpeg,png,gif,doc,docx,mp3,mp4,mpeg,mov,avi,txt,csv,xlsx,xls,pdf,wmv,mkv,mpg,zip" />
</FileFilters>
<Localization Select="<%$ Resources:lbSelect.Text %>" Remove="<%$ Resources:lbRemove.Text %>"/>
</telerik:RadAsyncUpload>
function onClientFileUploading1(sender, args) {
var saveButton = $find("<%= btnSave.ClientID %>");
saveButton.set_enabled(true);
}
function onClientFileRemove1(sender, args) {
var saveButton = $find("<%= btnSave.ClientID %>");
saveButton.set_enabled(false);
}
Telerik.Web.UI version is 2016.2.607.40, .net framework is 4.5.2
temporary file get deleted from server after 5 minutes if this setting is set to 5 minutes(expected);
temporary file get deleted from server after 20 minutes if this setting is set to 20 minutes(expected);
temporary file get deleted from server around 30 minutes if this setting is set to 1 hour or 4 hours.
Issue two-multiple temporary files get deleted at one time around 30 or 40 minutes even their uploaded time are different.
Example: a. set the expiration time to 20 minutes.
b. user1 uploaded file1 at 11:00AM,
c. user2 uploaded file2 at 11:05AM,
d. user1 saved file1 at 11:10Am and uploaded another file3 at 11:12AM
e. the expiration time for file2 should be 11:25PM and file3 should be 11:32PM base on the setting in step a. But actually, all files are removed around 11:21AM.
Issue is all files get removed at same time not base on their uploaded time. this is not expected and that means multiple user upload multiple files will have problem for sure.
Telerik.Web.UI version is 2016.2.607.40, .net framework is 4.5.2
You can find my answer in the other thread you posted in: https://www.telerik.com/forums/radasyncupload#TQhH_OHkgE6qvU8Xv3_Pog.
Let's keep this discussion in one place only to ensure thread coherence.
Regards,
Marin Bratanov
Progress Telerik
Hi Guys,
I have a similar issue with the RADAsyncUpload with certain files being prematurely deleted from the temporary folder.
This seems sporadic, but relatively reproducable with the correct files.
My Uploader:
I am using 2017.2.711.45
Multiple File Selection is enabled
I have a custom temporary folder specified
Custom HttpHandler is specified for asynchronous submission of the files
MaxFileSize is set to 10MB
MaxFileInputsCount is set to 5
AllowedExtensions are set (including specified file type).
Behaviour i am experiencing:
The file is uploaded to the temporary folder correctly, however, somewhere between 5 seconds to 1 minute, the file may be removed.
I cannot pinpoint any specific cause, however, this seems limited to larger files. I have been able to replicate on my system with a .mp4 of 3MB. I can provide this if could tell me how to get it to you.
Hi Simon,
You mentioned that you are using a custom handler -
Custom HttpHandler is specified for asynchronous submission of the files
What happens if you remove the custom handler and use the built-in one?
Also since 2017.2.711.45 is a relatively old version, can you please also test with the latest one 2020.1.219 which provides fixes and support for the latest browsers?
You can also test by changing the MaxFileSize to smaller file size for example 1 MB.
Regards,
Rumen
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Hi Rumen
Thanks for your reply. I have tested some more and i believe i have found the cause of my issue.
When i was creating the Upload Configuration, i believe i was instanciating it incorrectly.
I was doing the following:
var guid = Guid.NewGuid().ToString();
this
.rauUploader.UploadConfiguration =
new
RadAsyncUploadHandler.SampleAsyncUploadConfiguration { Guid = guid };
Whereas this has resolved the problem:
var guid = Guid.NewGuid().ToString();
var config = rauUploader.CreateDefaultUploadConfiguration<RadAsyncUploadHandler.SampleAsyncUploadConfiguration>();
config.Guid = hdnGuid.Value;
this
.rauUploader.UploadConfiguration = config;
Thank you for your time, i appreciate the help.