분노의 챔질
ASPxUploadControl로 증명사진업로드 본문
<dxuc:ASPxUploadControl ID="uploadImage" runat="server"
onfileuploadcomplete="uploadImage_FileUploadComplete"
ShowUploadButton="True" Width="100%" ClientInstanceName="uploadImage">
<ClientSideEvents FilesUploadComplete="function(s, e) {
cp.PerformCallback(s,e);
}" />
</dxuc:ASPxUploadControl>
<dxcp:ASPxCallbackPanel ID="ASPxCallbackPanel1" runat="server"
oncallback="ASPxCallbackPanel1_Callback" Width="120px"
ClientInstanceName="cp">
<PanelCollection>
<dxp:PanelContent runat="server">
<dxe:ASPxBinaryImage ID="picIdentificationPhoto" runat="server"
ClientInstanceName="picIdentificationPhoto" Height="140px" Width="120px">
<EmptyImage Url="~/images/noimage.gif" />
</dxe:ASPxBinaryImage>
</dxp:PanelContent>
</PanelCollection>
</dxcp:ASPxCallbackPanel>
ASPX.CS파일
protected void uploadImage_FileUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FileUploadCompleteEventArgs e)
{
Util.SetCookie("ImageName", uploadImage.PostedFile.FileName);
}
protected void ASPxCallbackPanel1_Callback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
string strFilePath = Util.GetCookie("ImageName");
this.picIdentificationPhoto.Value = ConvertImageToByteArray
(System.Drawing.Image.FromFile(strFilePath), ImageFormat.Jpeg);
}
private byte[] ConvertImageToByteArray(System.Drawing.Image imageToConvert, ImageFormat formatOfImage)
{
byte[] Ret;
try
{
using (MemoryStream ms = new MemoryStream())
{
imageToConvert.Save(ms, formatOfImage);
Ret = ms.ToArray();
}
}
catch (Exception) { throw; }
return Ret;
}
Util클래스
public static string GetCookie(string name)
{
if (HttpContext.Current.Request.Cookies.AllKeys.Where(o => o == name).Count() > 0)
{
return HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[name].Value);
}
else
return string.Empty;
public static void SetCookie(string name, string value)
{
HttpContext.Current.Response.Cookies.Add(new HttpCookie(name, HttpUtility.UrlEncodeUnicode
(value)));
}
'Programming > 기타' 카테고리의 다른 글
아스키 코드표 (0) | 2011.01.24 |
---|---|
제안서작성요령 (0) | 2010.08.20 |
유용한 무료폰트 사이트 (0) | 2010.04.30 |
데이터사전(Data Dictionary) (2) | 2010.04.27 |
ERD Tool (0) | 2010.04.21 |