When I try to submit this form, I am getting this error. This application runs perfectly as intended when I am running it locally but now that I have deployed the application on azure, I am getting this error: "Could not find a part of the path 'D:\home\site\wwwroot\DriverImage\image.jfif'."
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(str);
if (imageUpload.HasFile)
{
string isassigned = "no";
string filename = imageUpload.PostedFile.FileName;
string filepath = "DriverImage/" + imageUpload.FileName;
imageUpload.PostedFile.SaveAs(Server.MapPath("~/DriverImage/") + filename);
con.Open();
SqlCommand cmd = new SqlCommand("Insert into Drivers (firstname, lastname, gender, race, dob, image, isassigned) values('" + txtFirstName.Text + "', '" + txtLastName.Text + "', '" + drpGender.SelectedItem.Text + "', '" + drpRace.SelectedItem.Text + "', '" + Calendar1.SelectedDate.ToString("dd/MM/yyyy") + "', '" + filepath + "', '" + isassigned + "')", con);
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script>alert('Driver added successfully.');</script>");
Response.Redirect("AddDriver.aspx");
}
}
I have another file upload control for a different form that basically uses the same code but saves the image in a different folder and that works when deployed.