Topbar
Topbar
Sign in
|
Join
|
Client Center
Home
Products
Client Center
Contact
Purchase
Support forums
»
Products
»
Ajax Uploader
»
Re: How to get the photos selected using ajax multiple upload in code behind
Re: How to get the photos selected using ajax multiple upload in code behind
10-23-2009, 8:21 AM
cutechat
Joined on 07-22-2004
Posts 2,332
Re: How to get the photos selected using ajax multiple upload in code behind
Reply
Quote
Hi,
Please try this sample :
<
%@ Page
Language
=
"C#"
%
>
<
%@ Register
TagPrefix
=
"CuteWebUI"
Namespace
=
"CuteWebUI"
Assembly
=
"CuteWebUI.AjaxUploader"
%
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
script
runat
=
"server"
>
protected void Uploader1_FileUploaded(object sender, UploaderEventArgs args)
{
string
folder
=
Server
.MapPath("Photos");
if (!System.IO.Directory.Exists(folder))
System.IO.Directory.CreateDirectory(folder);
string
filepath
=
System
.IO.Path.Combine(folder, args.FileName);
if (System.IO.File.Exists(filepath))
System.IO.File.Delete(filepath);
//note : must set AllowedFileExtensions to prevent the client upload any aspx code which may be executed !
args.MoveTo(filepath);
Page.Title
=
"Uploaded : "
+ args.FileName;
Link1.Visible
=
true
;
Link1.NavigateUrl
=
"Photos/"
+ args.FileName;
Link1
Link1.Text
= Link1.NavigateUrl;
}
</
script
>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
>
Untitled Page
</
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
CuteWebUI:Uploader
runat
=
"server"
ID
=
"Uploader1"
OnFileUploaded
=
"Uploader1_FileUploaded"
>
<
ValidateOption
AllowedFileExtensions
=
"*.jpg,*.gif,*.png"
/>
</
CuteWebUI:Uploader
>
<
asp:HyperLink
runat
=
"server"
ID
=
"Link1"
Target
=
"_blank"
Visible
=
"false"
/>
</
form
>
</
body
>
</
html
>
Regards,
Terry
View Complete Thread