public byte[] GetByteArrayFromFileField(FileUpload FileField) { HttpPostedFile File = FileField.PostedFile; byte[] Data = new Byte[File.ContentLength]; File.InputStream.Read(Data, 0, File.ContentLength);
return Data; }
public string FileFieldType(FileUpload FileField) { // Returns the type of the posted file if (!(FileField.PostedFile == null)) { return FileField.PostedFile.ContentType; } else { return ""; } }
int FileFieldLength(FileUpload FileField) { // Returns the length of the posted file if (!(FileField.PostedFile == null)) { return FileField.PostedFile.ContentLength; } else { return 0; } }
SqlConnection con = new SqlConnection(CONNSTR); con.Open(); SqlCommand ins = new SqlCommand("INSERT INTO od VALUES (@id, @pic)", con); ins.Parameters.Add("@id", SqlDbType.Int); ins.Parameters.Add("@pic", SqlDbType.Image); ins.Parameters["@id"].Value = is; ins.Parameters["@pic"].Value = bytarr; ins.ExecuteNonQuery(); con.Close();
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.