74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using System;
|
|
using GZTW.AyaNova.BLL;
|
|
|
|
public partial class upload : BaseEditPage
|
|
{
|
|
|
|
protected void Page_Init()
|
|
{
|
|
if (AyaBizUtils.Right("Object.AyaFile") < (int)SecurityLevelTypes.ReadWrite)
|
|
{
|
|
Util.Denied(Context);
|
|
}
|
|
}
|
|
|
|
TypeAndID tid=null;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
tid = TypeAndID.ParseAyaURLQueryParameter(Server.UrlDecode(Request.Url.Query));
|
|
if (tid == null)
|
|
{
|
|
//problem, malformed url
|
|
throw new System.ApplicationException("upload->Url TypeAndID not recognized: " + Request.Url.Query);
|
|
}
|
|
|
|
//***** Max File size is 4MB for the upload control, this is a technical limit, not ours *****
|
|
|
|
//is file size larger than admin set value or default 4MB limit for uploading online?
|
|
long limit = AyaBizUtils.GlobalSettings.MaxFileSizeMB * 1048576;
|
|
if (limit > 4194304) limit = 4194304;
|
|
|
|
rup.MaxFileSize = (int)limit;
|
|
|
|
if (this.IsPostBack)//The only post back would be to edit the page
|
|
{
|
|
GetFiles();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void GetFiles()
|
|
{
|
|
if (rup.UploadedFiles.Count > 0)
|
|
{
|
|
AyaFileList list = AyaFileList.GetList(tid.ID);
|
|
for (int x = 0; x < rup.UploadedFiles.Count; x++)
|
|
{
|
|
Telerik.Web.UI.UploadedFile file = rup.UploadedFiles[x];
|
|
|
|
//Check for duplicate and remove if found
|
|
if (list.Contains(file.GetName()))
|
|
{
|
|
//Delete the original
|
|
AyaFile.DeleteItem(list[file.GetName()].Value.LT_O_AyaFile.Value);
|
|
}
|
|
AyaFile af = AyaFile.NewItem();
|
|
af.RootObjectID = tid.ID;
|
|
af.RootObjectType = tid.RootObjectType;
|
|
af.Name = file.GetName();
|
|
af.SetContent(file.InputStream);
|
|
af.Save();
|
|
}
|
|
CloseMe();
|
|
//Response.Redirect(Request.UrlReferrer.ToString(), true);
|
|
}
|
|
|
|
}
|
|
protected void Button1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
}
|
|
}
|