C# Fileupload控件在Chrome中不起作用,但在IE、ASP.NET中起作用
该代码仅适用于IE,因为Chrome只是提供文件控制的文件名,而IE提供完整路径。 如何使其与chrome一起工作? 我正在Sharepoint中上载并覆盖附件C# Fileupload控件在Chrome中不起作用,但在IE、ASP.NET中起作用,c#,asp.net,google-chrome,internet-explorer,sharepoint,C#,Asp.net,Google Chrome,Internet Explorer,Sharepoint,该代码仅适用于IE,因为Chrome只是提供文件控制的文件名,而IE提供完整路径。 如何使其与chrome一起工作? 我正在Sharepoint中上载并覆盖附件 foreach (GridViewRow row in GridView1.Rows) { if (row.RowType == DataControlRowType.DataRow) { FileUpload fileUpload = row.Cells[
foreach (GridViewRow row in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
FileUpload fileUpload = row.Cells[0].FindControl("FileUploadControl") as FileUpload;
if (fileUpload.HasFile)
{
filePath = fileUpload.PostedFile.FileName;
GetUrl(filePath);
}
}
}
public void GetUrl(string filePath)
{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (var clientContext = new ClientContext("http:/test/"))
{
using (var fs = new FileStream(filePath, FileMode.Open))
{
var fi = new FileInfo(filename);
var list1 = clientContext.Web.Lists.GetByTitle("Customer");
clientContext.Load(list1.RootFolder);
clientContext.ExecuteQuery();
var fileUrl = String.Format("{0}/Attachments/{1}/{2}", list1.RootFolder.ServerRelativeUrl, ids, fi.Name);
Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, fileUrl, fs, true);
}
}
});
}
不同的浏览器呈现它们的方式不同。尝试使用纯HTML文件上载控件。是否有其他方法使其与所有浏览器兼容?类似于读取文件而不是使用完整路径读取文件或任何其他解决方案?