Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Fileupload控件在Chrome中不起作用,但在IE、ASP.NET中起作用_C#_Asp.net_Google Chrome_Internet Explorer_Sharepoint - Fatal编程技术网

C# Fileupload控件在Chrome中不起作用,但在IE、ASP.NET中起作用

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[

该代码仅适用于IE,因为Chrome只是提供文件控制的文件名,而IE提供完整路径。 如何使其与chrome一起工作? 我正在Sharepoint中上载并覆盖附件

    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文件上载控件。是否有其他方法使其与所有浏览器兼容?类似于读取文件而不是使用完整路径读取文件或任何其他解决方案?