I use RadProgressManager and RadProgressArea with the rad upload control. it works fine in all browsers except safari 3 and above. This happend especially when i try to upload .flp and .cwk files.
If i upload a .doc or .txt file it works fine.
Please share some light on this.
----------------- Sample Code --------
<body>
<form id="form1" runat="server">
<div>
<label for="RadUploadMainFile0"><asp:Literal ID="ltlMainFile" runat="server" Text="file to upload: <span class='formalert'>*</span>" meta:resourcekey="lblMainFileResource1"></asp:Literal>
<asp:CustomValidator ID="MainFile" runat="server" ErrorMessage="You must select a main file."
ClientValidationFunction="Check" OnServerValidate="MainFile_ServerValidate" Display="Dynamic" CssClass="ErrorMessage" ForeColor="" ></asp:CustomValidator>
</label>
<radU:RadUpload ID="RadUpload" runat="server" ControlObjectsVisibility="None" OnClientFileSelected="SelectedFile" LocalizationPath="~/RadControls/Upload/Localization" ></radU:RadUpload>
<div ><asp:Literal ID="ltrFileName" runat="server" Text="Filename: " ><asp:Label id="lblFileName" runat="server" asp:Label></div>
<radU:RadProgressManager ID="Radprogressmanager1" runat="server" meta:resourcekey="Radprogressmanager1Resource1" />
<radU:RadProgressArea ID="progressArea1" runat="server" ProgressIndicators="TotalProgress, TotalProgressPercent, RequestSize, CurrentFileName" DisplayCancelButton="True" SkinsPath="Non-existingPath" meta:resourcekey="progressArea1Resource1" Language="" LocalizationPath="h:\RadControls\Upload//Localization" >
</radU:RadProgressArea>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" Visible="true" OnClick="Button1_Click" /></div>
</form>
</body>
8 Answers, 1 is accepted
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class TelerikUpLoadFile : System.Web.UI.Page
{
private const string PAGEKEY = "File";
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), PAGEKEY, GetClientSideScript());
if (!Page.IsPostBack)
{
if (!string.IsNullOrEmpty(Request.Params.Get("__EVENTARGUMENT"))
&& Request.Params.Get("__EVENTARGUMENT") == "FileUpload")
{
if ((RadUploadMain.UploadedFiles.Count > 0) && (RadUploadMain.UploadedFiles[0].ContentLength > 0))
{
lblFileName.Text = "Using telerik file is Uploaded: ";
}
}
}
}
private String GetClientSideScript()
{
string javascript = @"
<script language='javascript' type='text/javascript'>
var upLoadPath = '';
var upLoadFileName = '';
var isFileNameOnly = false;
// Updates the label lblFileName when the Uploadfile is selected
function FileSelected(radUpload, eventArgs)
{ alert('FileSelected');
upLoadPath = eventArgs.FileInputField.value;
alert('FileSelected2');
//extracts the file and path separately and returns them
var fileInfo = extractFileInfo(upLoadPath);
alert('fileInfo ' + fileInfo);
if(fileInfo.file != null)
upLoadFileName = fileInfo.file;
else
{
upLoadFileName = upLoadPath;
isFileNameOnly = true;
}
document.getElementById('lblFileName').innerHTML = upLoadFileName;
ValidatorValidate(CVMainFile);
document.getElementById('lblFileName').innerHTML = upLoadFileName;
//PostBack('','FileUpload');
}
//Checks wether the file is selected.
function FileCheck(source,args)
{
// Check any files is selected through the upload control
if( (upLoadFileName.length) > 0 )
{
document.getElementById('lblFileName').innerHTML = upLoadFileName;
args.IsValid = true;
}
// if Save button is clicked then the upLoadFileName.length will be zero
// and lblFileName.length willbe greater than zero.
else if(document.getElementById('lblFileName').innerHTML.length > 0)
{
args.IsValid = true;
}
else
{
"
+ RadUploadMain.ClientID + @".ClearFileInputAt(0);
document.getElementById('lblFileName').innerHTML = '';
upLoadFileName = '';
upLoadPath = '';
args.IsValid = false;
}
}
//The method forcefully post back, in order to upload files the
//whole form must be submitted.
function PostBack(eventTarget, eventArgument)
{
alert('fof');
__doPostBack(eventTarget, eventArgument);
return false;
}
function extractFileInfo(filePath)
{
var fileInfo = filePath.match(/(.*)[\/\\]([^\/\\]+\.\w+)$/);
if (fileInfo == null) {
return {path: null, file: null};
}
else {
return {path: fileInfo[1], file: fileInfo[2]}
}
}
</script>
";
// return the javascript
return javascript;
}
protected void CVMainFile_ServerValidate(object source, ServerValidateEventArgs args)
{
try
{
if ((RadUploadMain.UploadedFiles.Count > 0))
{
lblFileName.Text = "file copied sussessfully";
args.IsValid = true;
}
else
{
lblFileName.Text = "Error Error Error";
args.IsValid = false;
}
}
catch (Exception ex)
{
throw ex;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
if ((RadUploadMain.UploadedFiles.Count > 0))
{
lblFileName.Text = "file copied sussessfully through button click";
}
else
{
lblFileName.Text = "Error occured on button click";
}
}
catch (Exception ex)
{
throw ex;
}
}
}
Indeed, we found that the Safari browser (on Mac) fails uploading some types of files. To my regret we could not find the reason for that.
I believe it is a matter of a browser (or client computer) configuration though, because it is not persistent - we identified a case where we could upload one file from a machine and could not upload the same file from another machine (both uploads done from a Safari on Mac).
Regards,
Erjan Gavalji
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thanks for the quick reply.
In my case i dont think it is safari 3.x browser settings issue.
File upload of any type works fine in safari 2.x browsers.
In Safari 3.x browser - except .flp and .cwf file i can able to upload all other file type.
In order to make .flp and .cwk file work in safari 3.x browser i removed the RadProgressManager and RadProgressArea code from the aspx file, To my suprise it uploads fine.
Could you please help to sort this issue.
regards
Vijay
This is interesting indeed. To my regret we were not able to reproduce this problem with fake .flp and .cwf files.
Can you please attach the real problematic files to a formal support ticket so that we can use them for testing? We will do our best to have the issue solved once we are able to reproduce the problem on our side.
Kind regards,
Erjan Gavalji
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Could you please help me how can i upload a sample file with this message. I am trying to send you the samples but i could not find a attach button in this screen.
Thanks
Vijay
To preserve confidentiality, attachments are not allowed to the public forums. Please, open a support ticket for that.
Best,
Erjan Gavalji
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Hope you will be able to point me the right suggustion/solution to this issue.
We could not reproduce the problem at our side. We have attached a video showing our local tests.
Best wishes,
Veselin Vasilev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.