The SaveAs method is configured to require a rooted path, and the path '~\\images\\594083964.jpg' is not rooted

前端 未结 1 1068
执笔经年
执笔经年 2021-01-02 16:22

The SaveAs method is configured to require a rooted path, and the path \'~\\images\\594083964.jpg\' is not rooted. Description: An unhandled exception occurred during the ex

相关标签:
1条回答
  • 2021-01-02 17:10

    The path you are saving to is a relative URL. You need to save to a local file path (or full network path).

    Try:

    string relativePath = @"~\images\"+ i + Path.GetExtension(fu1.FileName);
    fu1.SaveAs(Server.MapPath(relativePath));
    

    (Path.GetExtension(string) will handle file extensions that aren't 3 characters too)

    0 讨论(0)
提交回复
热议问题