0
ファイルパスを自分のコードから抜き出し、mysqlのinsert文に入れますか?ファイルパスを自分のコードから抜き出し、mysqlの挿入ステートメントに入れますか?
string fileuploadpath = Server.MapPath("~/userdata/" + theUserId + "/uploadedimage/");
FileUploadControl.SaveAs(Path.Combine(fileuploadpath , filename));
へ
protected void UploadButton_Click(object sender, EventArgs e)
{
string theUserId = Session["UserID"].ToString();
{
OdbcConnection cn = new OdbcConnection("Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=gymwebsite2; User=root; Password=commando;");
cn.Open();
}
if (FileUploadControl.HasFile)
{
try
{
string filename = Path.GetFileName(FileUploadControl.FileName);
string fileuploadpath = Server.MapPath("~/userdata/" + theUserId + "/uploadedimage/");
FileUploadControl.SaveAs(Path.Combine(fileuploadpath, + filename));
//error on this line best overload method has some invalid arguements
StatusLabel.Text = "Upload status: File uploaded!";
//some kind of function to take the path then enter it into my insert syntax?
OdbcCommand cmd = new OdbcCommand("INSERT INTO Pictures (UserID, picturepath) VALUES ('"+ theUserId +"' , '"+ fileuploadpath +"')", cn);
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
}
}
}
私はこの行でエラーが発生します:FileUploadControl.SaveAs(Path.Combine(fileuploadpath、+ filename)); (括弧内のエラー) –
最適なオーバーロードメソッドに無効な引数があります –
oops、typo。一定 –