小编Nei*_*eil的帖子

上传图像在服务器上不起作用

在将文件从本地计算机上传到服务器时,它正在向我显示

"Server Error in '/' Application.
Access to the path 'G://images\blog-image2.jpg' is denied."
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我....请.我的c#代码是这样的:

protected void btnSubmit_Click(object sender, EventArgs e)
{
    //Get Filename from fileupload control
    string filename = Path.GetFileName(fileuploadimages.PostedFile.FileName);
    //Save images into Images folder
    fileuploadimages.SaveAs(Server.MapPath("~/images/" + filename));

    //Getting dbconnection from web.config connectionstring
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconnection"].ToString());
    //Open the database connection
    con.Open();
    //Query to insert images path and name into database
    SqlCommand cmd = new SqlCommand("Insert into tblimgs(ImageName,ImagePath) values(@ImageName,@ImagePath)", con);
    //Passing parameters to query
    cmd.Parameters.AddWithValue("@ImageName", filename);
    cmd.Parameters.AddWithValue("@ImagePath", "~/images/" + …
Run Code Online (Sandbox Code Playgroud)

c# asp.net

7
推荐指数
1
解决办法
1203
查看次数

标签 统计

asp.net ×1

c# ×1