string sqlConnectionString = "Your conection string."; SqlConnection sqlConnection = new SqlConnection(sqlConnectionString); string sqlCommandString = "Insert Into [UploadFile] ([FileName], [ContentType], [BinaryStream]) Values (@FileName, @ContentType, @BinaryStream)"; SqlCommand sqlCommand = new SqlCommand(sqlCommandString, sqlConnection); sqlCommand.Parameters.Add("@FileName", SqlDbType.NVarChar); sqlCommand.Parameters.Add("@ContentType", SqlDbType.NVarChar); sqlCommand.Parameters.Add("@BinaryStream", SqlDbType.Image); sqlCommand.Parameters["@ContentType"].Value = FileUpload1.PostedFile.ContentType; sqlCommand.Parameters["@FileName"].Value = FileUpload1.PostedFile.FileName; BinaryReader BinaryRead = new BinaryReader(FileUpload1.PostedFile.InputStream); byte[] BinaryData = BinaryRead.ReadBytes(FileUpload1.PostedFile.ContentLength); sqlCommand.Parameters["@BinaryStream"].Value = BinaryData; sqlCommand.ExecuteNonQuery();
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง