Hi ,
I am using Radupload control to upload multiple files in my project.It Working Correctly on uploading single file .But It Is not working Multiple Files.It Upload only one file in multiple times with same name.Please give me the Solution.
In My aspx page:
<telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1"
TargetFolder="~/uploadattachment/" AllowedFileExtensions=".pdf,.doc,.docx,.txt,.gif,.jpg,jpeg,.png"
MaxFileSize="524288" Skin="Simple" MultipleFileSelection="Automatic" UploadedFilesRendering="BelowFileInput"
ChunkSize="0" Style="margin-right: 110px; margin-top: 10px" OnFileUploaded="RadAsyncUpload1_FileUploaded">
</telerik:RadAsyncUpload>
In My .cs page:
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
string fileid;
UploadedFile file = RadAsyncUpload1.UploadedFiles[0];
string filename = file.FileName;
string pathname = Path.GetFileName(filename);
string targetfolder = Server.MapPath(RadAsyncUpload1.TargetFolder);
string folderpath = targetfolder + filename;
string temp = "";
string fname = "";
int cnt = 1;
if (File.Exists(folderpath))
{
for (int i = 1; i <= cnt; i++)
{
string woext = Path.GetFileNameWithoutExtension(filename);
string ext = Path.GetExtension(filename);
string addnum = woext + "(" + cnt + ")";
temp = addnum + ext;
if (File.Exists(targetfolder + temp))
cnt++;
}
fname = temp;
e.File.SaveAs(Server.MapPath("~/uploadattachment/" + fname));
fileid = fname;
builder.Append(fileid).Append(",");
}
else
{
e.File.SaveAs(Server.MapPath("~/uploadattachment/" + filename));
fileid = filename;
builder.Append(fileid).Append(",");
// Id = builder.ToString();
}
Id = builder.ToString();
}
I am using Radupload control to upload multiple files in my project.It Working Correctly on uploading single file .But It Is not working Multiple Files.It Upload only one file in multiple times with same name.Please give me the Solution.
In My aspx page:
<telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1"
TargetFolder="~/uploadattachment/" AllowedFileExtensions=".pdf,.doc,.docx,.txt,.gif,.jpg,jpeg,.png"
MaxFileSize="524288" Skin="Simple" MultipleFileSelection="Automatic" UploadedFilesRendering="BelowFileInput"
ChunkSize="0" Style="margin-right: 110px; margin-top: 10px" OnFileUploaded="RadAsyncUpload1_FileUploaded">
</telerik:RadAsyncUpload>
In My .cs page:
protected void RadAsyncUpload1_FileUploaded(object sender, Telerik.Web.UI.FileUploadedEventArgs e)
{
string fileid;
UploadedFile file = RadAsyncUpload1.UploadedFiles[0];
string filename = file.FileName;
string pathname = Path.GetFileName(filename);
string targetfolder = Server.MapPath(RadAsyncUpload1.TargetFolder);
string folderpath = targetfolder + filename;
string temp = "";
string fname = "";
int cnt = 1;
if (File.Exists(folderpath))
{
for (int i = 1; i <= cnt; i++)
{
string woext = Path.GetFileNameWithoutExtension(filename);
string ext = Path.GetExtension(filename);
string addnum = woext + "(" + cnt + ")";
temp = addnum + ext;
if (File.Exists(targetfolder + temp))
cnt++;
}
fname = temp;
e.File.SaveAs(Server.MapPath("~/uploadattachment/" + fname));
fileid = fname;
builder.Append(fileid).Append(",");
}
else
{
e.File.SaveAs(Server.MapPath("~/uploadattachment/" + filename));
fileid = filename;
builder.Append(fileid).Append(",");
// Id = builder.ToString();
}
Id = builder.ToString();
}