关于UploadFile(C#)
来源:百度知道 编辑:UC知道 时间:2024/06/27 23:48:19
string ImgName = textBox21.Text.Substring(textBox21.Text.LastIndexOf(@"\")+1);\\文件名截取,这个没有错
string Url = @"JF\\F\image\" + ImgName;\\(这里写成string Url = @"F:\image\" + ImgName;的话就没错了,但是我需要在局域网里传,JF是计算机名)
Web.UploadFile(Url,"STOR", ImgName);\\指定的路径访问被拒绝
一楼的方法,提示“不支持给定路径的格式”。
WebClient web = new WebClient();
web.UploadFile(url, "post", filename);
你那个上传页面做了么?
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 Admin_person_uphetong : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
foreach (string f in Request.Files.AllKeys)
{
HttpPostedFile file = Request.Files[f];
file.SaveAs(Server.MapPath("hetong") + "\\" + file.FileName);
}
if (Request.Params["testKey"] != null)
{
Response.Write(Request.Params["testKey"]);
}
}