上传文件到服务器,代码要怎么写?
现代码只能上传到本地,要上传到服务器要怎么改?服务器那边要怎么接受,我用的是uploadify上传插件。
public ActionResult AppTemplateUpload()
{
Response.ContentType = "text/html";
Response.Charset = "utf-8";
HttpPostedFile file = Request.Files["Filedata"];
decimal size = Convert.ToDecimal(file.ContentLength) / (1024 * 1024);
decimal fileSize = Math.Round(size, 2);
string httpPath = "appapitest.gamersky.com" + "/";
const string upload = "UploadFiles\\AppVersionCode\\";
string uploadPath = AppDomain.CurrentDomain.BaseDirectory + upload;
string identify = DateTime.Now.ToString("yymmddhhmmss");
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
file.SaveAs(uploadPath + identify + file.FileName);
var UploadPath = httpPath + "Template/" + identify + file.FileName;
HttpResult hr = new HttpResult() { StatusCode = 1, Message = UploadPath, OtherParameter = fileSize.ToString() };
return new JsonResult(hr);
}
public ActionResult AppTemplateUpload()
{
Response.ContentType = "text/html";
Response.Charset = "utf-8";
HttpPostedFile file = Request.Files["Filedata"];
decimal size = Convert.ToDecimal(file.ContentLength) / (1024 * 1024);
decimal fileSize = Math.Round(size, 2);
string httpPath = "appapitest.gamersky.com" + "/";
const string upload = "UploadFiles\\AppVersionCode\\";
string uploadPath = AppDomain.CurrentDomain.BaseDirectory + upload;
string identify = DateTime.Now.ToString("yymmddhhmmss");
if (!Directory.Exists(uploadPath))
{
Directory.CreateDirectory(uploadPath);
}
file.SaveAs(uploadPath + identify + file.FileName);
var UploadPath = httpPath + "Template/" + identify + file.FileName;
HttpResult hr = new HttpResult() { StatusCode = 1, Message = UploadPath, OtherParameter = fileSize.ToString() };
return new JsonResult(hr);
}
...全文
相关推荐
3.18号日报,ctfhub中web,文件上传漏洞题目解法
文件上传漏洞
简单的php文件上传(实例)
PHP上传类太多,这里提供一个简单的php文件上传,一个文件就可以搞定上传。
Struts2下多文件的上传与下载
在网络上,对于Java处理文件上传和下载的技术比较多,而Struts作为一款优秀的框架也提供了非常方便的文件上传和下载,而网上的一些例程都非常的不全面,概括来: 1) 文件上传比较多,多文件上传少一点 2) 文件下载很少的,看似简单,实则不然 3) 文件下载一般都是单文件或者固定的文件,并没有(很少)实现随意文件的下载的例子 最近也在研究一下文件的上传和下载,在整合网上、浪曦风中叶老师和自己的学习的思想,写了这个工程,提供给大家参考,所以的代码终在IE、FireFox、Chrome测试通过。
使用HTTP上传文件到WEB服务器
最近很多人向我HTTP上传文件到WEB上,我就放在网络上共享,我比较忙,没空一个一个发,现上传上来了
python3写的简单本地文件上传服务器实例
今天小编就为大家分享一篇python3写的简单本地文件上传服务器实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧


