Tag: 文件上传

FileUpload – 如果文件名存在,则在名称末尾的括号之间连接一个数字

我想将文件(一次一个)上传到文件夹: GetUniqueName函数(如下所述)将返回唯一的文件名 这是我用来做的代码: public static string GetUniqueName(string fileName) { string dir = Globals.Directories.GetCustomCategoryThumbnailDir(); string fileExtension = Path.GetExtension(fileName); string fileNameWE = Path.GetFileNameWithoutExtension(fileName); string[] files = Directory.GetFiles(dir, “*” + fileExtension) .Select(Path.GetFileName) .ToArray(); string uniqueName = fileNameWE; int nextNum = 0; bool fileExist = false; string pattern = @”(.*)\(([\d]+)\)”; foreach (var file in files) { var tempFileName = […]

文件上传进度

我需要在我的网页上实现文件上传进度我的页面中有五个文件上传控件,我想分别显示每个文件上传的上传进度。 我有办法做到这一点。 感谢Muthuraman。

上传前validation文件大小

我需要validation要上传到服务器的文件。 validation必须在上传之前完成。 即,validation在客户端完成。 此任务应在ASP.NET MVC3网页中完成。 它也适用于所有浏览器。 IE9,8,7 / FF / Chrome浏览器。 我开始知道IE没有FileReader API。 我的问题是,如何在MVC3网页上传之前validation文件大小。

ASP.NET文件上载控件允许的最大文件大小

我在ASP.Net中使用文件上传控件,遵循以下博客方法。 http://weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads-in-asp-net.aspx 4MB默认值在machine.config中设置,但您可以在web.config中覆盖它。 例如,要将上传限制扩展到20MB,您可以这样做: 问题:如果我们允许用户上传50-60 MB文件,那么我可以增加所请求的长度以及对网站的性能影响。

如何正确使用ASP.NET FileUpload控件

我正在尝试在ASP.NET中使用FileUpload控件 这是我当前的命名空间设置: using System; using System.IO; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; 在我的课堂上,我只是使用: FileUpload fileUpload = new FileUpload(); 但是,通常不属于FileUpload的属性似乎都不可用……例如.HasFile。 我试图在后面的代码中使用Button click方法,我注意到.HasFile的大多数用法都在前面的代码中,但是我的理解是这不应该重要。 有谁知道为什么?

如何保存上传的文件? c#mvc

我想将一个图像文件上传到项目的文件夹,但是我的catch中有一个错误:无法找到路径’C:\ project \ uploads \ logotipos \ 11111 \’的一部分。 我做错了什么? 我希望保存我的客户端在该文件夹中上传的图像…该文件夹存在…啊,如果我为folder_exists3设置一个断点,显示一个真正的值! 我的代码是: try { var fileName = dados.cod_cliente; bool folder_exists = Directory.Exists(Server.MapPath(“~/uploads”)); if(!folder_exists) Directory.CreateDirectory(Server.MapPath(“~/uploads”)); bool folder_exists2 = Directory.Exists(Server.MapPath(“~/uploads/logo”)); if(!folder_exists2) Directory.CreateDirectory(Server.MapPath(“~/uploads/logo”)); bool folder_exists3 = Directory.Exists(Server.MapPath(“~/uploads/logo/” + fileName)); if(!folder_exists3) Directory.CreateDirectory(Server.MapPath(“~/uploads/logo/”+fileName)); file.SaveAs(Server.MapPath(“~/uploads/logo/” + fileName+”/”)); } catch(Exception e) { } 有人知道我做错了什么? 谢谢 :)

ASP.NET:在客户机上获取文件路径(任何可能的解决方案/解决方法?)

我在.aspx页面上有一个文件上传控件,我在那里提取基本文件信息。 要求是我需要将所选文件的绝对路径从客户机的机器保存到数据库。 我已经阅读过这个网站以及其他地方的ASP.NET本质上由于安全原因不允许从客户机上读取信息。 但我想知道是否有办法解决这个问题,使用js或其他东西来获取绝对路径,然后将其传递给asp.net变量?

文件上载,远程服务器返回错误:(413)请求实体太大

当我通过WCF服务上传文件时,我收到exception,“远程服务器返回错误:(413)Request Entity Too Large” 关于这个例外,有很多问题和答案。 但是,他们都没有解决我的问题。 我正在使用Windows Web Server 2008 R2,IIS 7.5。 我的客户端和WCF应用程序托管在IIS中。 我正在使用频道来呼叫WCF服务。 var binding = new BasicHttpBinding(); binding.MaxReceivedMessageSize = Int32.MaxValue; binding.MaxBufferPoolSize = Int32.MaxValue; binding.MaxBufferSize = Int32.MaxValue; binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; binding.ReaderQuotas.MaxArrayLength = Int32.MaxValue; binding.ReaderQuotas.MaxBytesPerRead = Int32.MaxValue; binding.ReaderQuotas.MaxDepth = Int32.MaxValue; binding.ReaderQuotas.MaxNameTableCharCount = Int32.MaxValue; var address = new EndpointAddress(“WCF Service URL”); return ChannelFactory.CreateChannel(binding, address); WCF配置文件如下: 另外,我在客户端web.config文件中添加了以下配置: […]

从c sharp客户端应用程序上传到PHP服务器

目前我有一个尖锐的应用程序(客户端应用程序) 和一个写PHP的Web应用程序。 我想在客户端执行特定操作时传输一些文件。 这是将文件上传到php服务器的客户端代码.. private void button1_Click(object sender, EventArgs e) { System.Net.WebClient Client = new System.Net.WebClient(); Client.Headers.Add(“Content-Type”, “binary/octet-stream”); byte[] result = Client.UploadFile(“http://localhost/project1/upload.php”, “POST”, @”C:\test\a.jpg”); string s = System.Text.Encoding.UTF8.GetString(result, 0, result.Length); } 这是用于移动文件的upload.php文件.. $uploads_dir = ‘./files/’; //Directory to save the file that comes from client application. foreach ($_FILES[“pictures”][“error”] as $key => $error) { if ($error == […]

上传HTTP进度跟踪

我有WPF应用程序,我写的是将文件发布到社交网络之一。 上传本身工作得很好,但我想提供一些指示,说明我在上传方面有多远。 我尝试了很多方法来做到这一点: 1)HttpWebRequest.GetStream方法: using ( var FS = File.Open( localFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { long len = FS.Length; HttpWebRequest request = (HttpWebRequest) WebRequest.Create(url); request.Method = “POST”; request.ProtocolVersion = HttpVersion.Version11; request.ContentType = “multipart/form-data; boundary=–AaB03x”; //predata and postdata is two byte[] arrays, that contains //strings for MIME file upload (defined above and is not important) request.ContentLength […]