Files
Facilitor/APPL/Shared/base64_png_save.asp
Jos Groot Lipman 39a07e8d1f FSN#37809 Goede mimetype voor handtekening PNG's
svn path=/Website/trunk/; revision=30847
2016-09-26 09:14:21 +00:00

77 lines
2.8 KiB
Plaintext

<%@ LANGUAGE = JavaScript %>
<% /*
$Revision$
$Id$
File: savepng.asp
Description: Opvangscript van uploadform.asp
Parameters:
extfilter extensie filter
pkey ALG_RUIMTE_KEY of ...
pModule "ALG" of ...
pKenmerk_key ALG_KENMERK_KEY of ...
Context: Vanuit uploadform.asp
Note: Met TAMPER bescherming!
*/
JSON_Result = true;
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="./flexfiles.inc" -->
<!-- #include file="../Shared/json2.js" -->
<!-- #include file="../Shared/kenmerk_common.inc" -->
<%
protectQS.verify(); // tamper check
var pKey = getQParamInt("key", -1);
var pNiveau = getQParamSafe("niveau", "");
var pModule = getQParamSafe("module");
var pKenmerk_key = getQParamInt("kenmerk_key", -1);
var params = flexProps(pModule, pKey, String(pKenmerk_key), pNiveau);
__Log("Opslaan onder: " + params.AttachPath);
CreateFullPath(params.AttachPath);
var fso = Server.CreateObject("Scripting.FileSystemObject")
var f = fso.GetFolder(params.AttachPath);
for (fc = new Enumerator(f.files); !fc.atEnd(); fc.moveNext())
{
var vFileName = fc.item().Name;
__Log("Autodelete: " + params.AttachPath + vFileName)
DeleteFile(params.AttachPath + vFileName);
}
var data = getFParam("data", "");
var result = {};
if (data)
{
var Attachment = data.split(",")[1]; // haal data:image/png;base64, er af
var now = new Date();
var SafeName = "signature_{0}-{1}-{2}_{3}-{4}-{5}.png".format(padout(now.getFullYear()),
padout(now.getMonth()+1),
padout(now.getDate()),
padout(now.getHours()),
padout(now.getMinutes()),
padout(now.getSeconds()));
try
{
encodedString2File(params.AttachPath + SafeName, Attachment, "bin.base64");
checkWebconfig(params.AttachRootPath);
var transitParam = buildTransitParam(["tmpfolder"]);
result.safefilename = SafeName;
result.fullPath = protectQS.create(OpenFlexFile(pModule, pNiveau, pKey, pKenmerk_key, SafeName, { mime_type: "image/png", contentdp: "inline" }) + transitParam);
}
catch (e)
{
result.message = L("lcl_shared_upload_error_start") + e.description + L("lcl_shared_upload_error_end");
}
}
result.success = true;
Response.Write(JSON.stringify(result));
Response.End;
%>