change image path for upload control dynamically

Griegaiff

New Member
I am working in ASP.NET and C#.I have an \[code\]Fileupload\[/code\] control in my application. I want to change the storage path (on the hard disk) of the image during the upload. How do I go about it.C# code:\[code\] string filename = Path.GetFileName(fileuploadimages.PostedFile.FileName); //Save images into Images folder fileuploadimages.SaveAs(Server.MapPath("**~/database/**" + filename)); //Getting dbconnection from web.config connectionstring SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString()); //Open the database connection con.Open(); //Query to insert images path and name into database SqlCommand cmd = new SqlCommand("Insert into tblImageupload1(Imagename,Imagepath) values(@ImageName,@ImagePath)", con); //Passing parameters to query cmd.Parameters.AddWithValue("@Imagename", filename); cmd.Parameters.AddWithValue("@Imagepath", "../Database/" + filename); //cmd.Parameters.Add("@price"); cmd.ExecuteNonQuery(); //Close dbconnection con.Close();\[/code\]Note: I want to change the path \[code\]~/database/\[/code\] dynamically during upload.
 
Back
Top