save.aspx

来自「applet在線上繪圖,允許在瀏覽器上繪圖,最後儲存成各式的圖檔」· ASPX 代码 · 共 36 行

ASPX
36
字号
<%@ Page Language="C#" %>
<%
/*----------------------------------------------------------------------------
' This script accepts the image from the editor and saves it to a disk file.
' Then it asks the applet to redirect the browser to the 'view.asp'
' to prove that the image is saved successfully.
'----------------------------------------------------------------------------*/

// let's save images to the script's directory
string filePath = Server.MapPath("./");

HttpFileCollection postedFileCollection = Request.Files;

if (postedFileCollection.Count > 0) {
    HttpPostedFile postedFile = Request.Files[0];
    
    // we use here the file name suggested by the applet
    string fileName = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf("\\")+1);

    // but you can use any naming strategy, for example:
    // fileName = "XYZ12345.PNG";

    // save the uploaded image
    postedFile.SaveAs(filePath+"\\"+fileName);
    
    // Ask the applet to redirect the user's browser to the 'view.aspx' page
    Response.Write("#SHOWDOCUMENT=view.aspx?filename=" + fileName + "\n");
}
else {
     // No file has been uploaded
     // Ask the applet to report the error to the browser's status line
     Response.Write("#SHOWSTATUS=No file has been uploaded\n");
}

%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?