using System;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
public partial class Jscript_KindEditor_upload_cgi_upload :
{
protected void Page_Load(object sender, EventArgs e)
{
// File save directory path
string SavePath = "/Upload_Images/";
//File save directory URL
string SaveUrl = "/Upload_Images/";
//Upload image type
string[] ExtStr=new string[4];
ExtStr[0] = ".gif";
ExtStr[1] = ".jpg";
ExtStr[2] = ".png";
ExtStr[3] = ".bmp";
//The maximum size of the picture
int MaxSize = 100000;
//Error message
string[] MsgStr = new string[3];
MsgStr[0] = "The upload file size exceeds the limit.";
MsgStr[1] = "Upload file extension is an unsubscribed extension.";
MsgStr[2] = "Uploading the file failed //nPlease try again.";
string imgWidth = ["imgWidth"];
string imgHeight = ["imgHeight"];
string imgBorder = ["imgBorder"];
string imgTitle = ["imgTitle"];
string imgAlign = ["imgAlign"];
string imgHspace = ["imgHspace"];
string imgVspace = ["imgVspace"];
HttpPostedFile imgFile = ["imgFile"];
//Get the file name
string FileName = ();
if (FileName != "")
{
if ( > MaxSize)
{
Alert(MsgStr[0]);
}
else
{
string fileExtension = (FileName).ToLower();
if (CheckExt(ExtStr, fileExtension))
{
//Rename the file, time milliseconds part + extension
string imgReName = "" + ("yyyy-MM-dd-HH-mm-ss-ffff", ) + "" + fileExtension;
//Folder name
string imgFolderName=("yyyyMMdd",);
try
{
if (!(@("" + SavePath + "" +imgFolderName + "")))
{
// Generate the complete directory of the file
(@("" + SavePath + "" +imgFolderName + ""));
}
(@("" + SavePath + "" + imgFolderName + "/")+imgReName);
}
catch
{
Alert(MsgStr[2]);
}
string imgUrl = SaveUrl + imgFolderName + "/" + imgReName;
ReturnImg(imgUrl, imgWidth, imgHeight, imgBorder, imgTitle, imgAlign, imgHspace, imgVspace);
}
else
{
Alert(MsgStr[1]);
}
}
}
}
/// <summary>
/// Prompt to close the layer
/// </summary>
/// <param name="MsgStr"></param>
private void Alert(string MsgStr)
{
("<html>");
("<head>");
("<title>error</title>");
("<meta http-equiv=/"content-type/" content=/"text/html; charset=utf-8/">");
("</head>");
("<body>");
("<script type=/"text/javascript/">alert(/"" + MsgStr + "/");();();</script>");
("</body>");
("</html>");
}
/// <summary>
/// Detect file type
/// </summary>
/// <param name="ExtStr"></param>
/// <param name="fileExt"></param>
/// <returns></returns>
private bool CheckExt(string[] ExtStr,string fileExt)
{
for (int i = 0; i < ; i++)
{
if (ExtStr[i] != fileExt)
{
return true;
}
}
return false;
}
/// <summary>
/// Return to picture
/// </summary>
/// <param name="FileUrl"></param>
/// <param name="FileWidth"></param>
/// <param name="FileHeight"></param>
/// <param name="FileBorder"></param>
/// <param name="FileTitle"></param>
/// <param name="FileAlign"></param>
/// <param name="FileHspace"></param>
/// <param name="FileVspace"></param>
private void ReturnImg( string FileUrl,string FileWidth,string FileHeight,string FileBorder,string FileTitle,string FileAlign,string FileHspace,string FileVspace)
{
("<html>");
("<head>");
("<title>Uploaded successfully</title>");
("<meta http-equiv=/"content-type/" content=/"text/html; charset=utf-8/">");
("</head>");
("<body>");
("<script type=/"text/javascript/">(/"" + FileUrl +"/",/"" + FileWidth + "/",/"" + FileHeight + "/",/"" + FileBorder + "/",/"" + FileTitle + "/",/"" + FileAlign + "/",/"" + FileHspace + "/",/"" + FileVspace + "/");</script>");
("</body>");
("</html>");
}
}