页面:

<body>
  <form >
    <table>
      <tr>
        <td>图片:</td>
        <td><input type="file" name="file" accept="image/*" value="选择" /></td>
      </tr>
    </table>
    <input type="submit" value="上传" />
  </form>
</body>

后台:

public string Upload()
{
  HttpPostedFileBase file = Request.Files["file"];
  if (file.ContentLength > 0)
  {
    string savePath = Server.MapPath("~/Uploads/Pictures");
    string failPath = savePath + "\\"  + file.FileName;
    file.SaveAs(failPath);
    return “图片上传成功!”;
  }
  else
  {
    return "未选择图片!";
  }
}

相关文章:

  • 2022-01-01
  • 2021-12-22
  • 2021-12-22
  • 2021-12-22
  • 2021-10-07
  • 2021-12-22
  • 2022-12-23
猜你喜欢
  • 2021-07-13
  • 2022-12-23
  • 2022-02-27
  • 2021-12-02
  • 2021-12-22
  • 2022-12-23
  • 2021-11-23
相关资源
相似解决方案