다음과 같은 코드를 확인할 수 있습니다하려고 생각 그것은 내 데이터베이스에 직접.
<telerik:RadAsyncUpload runat="server" ID="RadAsyncUpload1" MaxFileSize="57971152"
DisableChunkUpload="true" HttpHandlerUrl="~/RadAsyncUpload/Handler.ashx" UploadedFilesRendering="BelowFileInput">
</telerik:RadAsyncUpload>
Handler.ashx :
<%@ WebHandler Language="C#" Class="CustomHandler" %>
using System;
using System.Web;
using Telerik.Web.UI;
public class CustomHandler : AsyncUploadHandler
{
protected override IAsyncUploadResult Process(UploadedFile file, HttpContext context, IAsyncUploadConfiguration configuration, string tempFileName)
{
System.IO.Stream fileStream = file.InputStream;
byte[] attachmentBytes = new byte[fileStream.Length];
fileStream.Read(attachmentBytes, 0, Convert.ToInt32(fileStream.Length));
System.Data.SqlClient.SqlConnection conn = null;
try
{
try
{
conn = new System.Data.SqlClient.SqlConnection(
System.Configuration.ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
conn.Open();
System.Data.SqlClient.SqlCommand insertCommand =
new System.Data.SqlClient.SqlCommand(
"Insert into [Pictable] (msgid, pic1) Values (1, @Pic)", conn);
insertCommand.Parameters.Add("@Pic", System.Data.SqlDbType.VarBinary).Value = attachmentBytes;
int queryResult = insertCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
}
}
finally
{
if (conn != null)
{
fileStream.Close();
conn.Close();
}
}
return CreateDefaultUploadResult<UploadedFileInfo>(file);
}
}
덕분에, 내가 데모 같은 구문을해야 할 이유 – user3201543