ASDL#37188 Logboek NS: Mogelijkheid om meerdere foto's tergelijk opsturen

svn path=/Website/trunk/; revision=30551
This commit is contained in:
Erik Groener
2016-09-05 12:06:50 +00:00
parent 3ed987c9c0
commit d7dc5b00e5
3 changed files with 144 additions and 123 deletions

View File

@@ -214,9 +214,12 @@ if (fso.FolderExists(params.AttachPath))
document.forms.u2.submit();
}
function uploadDone(uploaded_file)
function uploadDone(uploaded_files)
{
FcltMgr.topmanager().window.$.toast({ text: L("lcl_appendix_added").format(uploaded_file), icon: "success", position : 'top-center'});
for (i=0; i<uploaded_files.length; i++)
{
FcltMgr.topmanager().window.$.toast({ text: L("lcl_appendix_added").format(uploaded_files[i]), icon: "success", position : 'top-center'});
}
window.location = "<%=protectQS.create("BijlagenForm.asp?x=x"+transitParam)%>";
}
@@ -321,10 +324,11 @@ if (fso.FolderExists(params.AttachPath))
if (!pReado && (pMulti || params.multi || fileArray.length == 0)) // Uploadknop erbij
{
buttons.push({ title: L("lcl_do_upload_image"), action: "doSubmitUpload()", singlepress: true, id: "btn_upload_submit"});
var isMultiple = (((pMulti || params.multi) && !params.forcesingle) ? "multiple" : "");
%> <tr><td colspan="4">
<label><%=L("lcl_upload_file")%>:</label>
<% if (params.extFilter) { Response.Write("(" + safe.html(params.extFilter) + ")"); } %>
<input type="file" multiple name="imgfile" style="width: 95%" onchange="iface.button[this.value?'enable':'disable']('btn_upload_submit')">
<input type="file" <%=isMultiple%> name="imgfile" style="width: 95%" onchange="iface.button[this.value?'enable':'disable']('btn_upload_submit')">
<div id="uploading" style="display:none">
Please wait...
</div>

View File

@@ -72,8 +72,12 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
}
var VB_result = VB_getfiles();
var result = { message: VB_result("message"),
safefilename: []
};
//__Log(found_fields);
//__Log(found_files);
protectRequest.validateToken(found_fields["__RequestVerificationToken"]);
@@ -83,6 +87,7 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
{
var finfo = found_files[j];
var safefilename = safe.filename(finfo.name);
result.safefilename.push(safefilename);
var BinaryStream = Server.CreateObject("ADODB.Stream");
BinaryStream.Type = 1; // adTypeBinary
BinaryStream.Open();
@@ -98,13 +103,8 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
{
HELP;
}
}
var result = { message: VB_result("message"),
safefilename: VB_result("safefilename")
};
//__Log(result);
// Toevoegen bijlage/bestand tracken.
if (pKey > -1 && params.trackcode && (params.kenmerktype == "E" || params.kenmerktype == "F" || params.kenmerktype == "M"))
@@ -119,27 +119,36 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
oRs.close();
pKey = String(afspr_key);
}
var ptxt = L("lcl_shared_attachment_add").format(params.kenmerkoms, found_files[0].name);
for (j=0; j<result.safefilename.length; j++)
{
ptxt = L("lcl_shared_attachment_add").format(params.kenmerkoms, result.safefilename[j]);
shared.trackaction(params.trackcode, pKey, ptxt);
}
}
if (!result.message && params.forcesingle)
{
{ // Er mag maar 1 bestand bestaan.
// Verwijder alle andere bestanden.
if (result.safefilename.length>1)
{
result.message += L("lcl_shared_upload_toomany");
}
else
{
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;
if (vFileName != VB_result("safefilename"))
if (vFileName != result.safefilename[0])
{
__Log("Autodelete: " + params.AttachPath + vFileName)
DeleteFile(params.AttachPath + vFileName);
}
}
}
}
if (result.message && result.message != "")
{
@@ -149,8 +158,11 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
{
checkWebconfig(params.AttachRootPath);
for (j=0; j<result.safefilename.length; j++)
{
result_safefilename = result.safefilename[j];
// Eerst Resize/crop
if (params.regexp && result.safefilename.match(/\.(png|jpg|jpeg)$/i))
if (params.regexp && result_safefilename.match(/\.(png|jpg|jpeg)$/i))
{
var Format = params.regexp.match(/^([RrCc])(\d*)x(\d*)$/i); // P800x600
if (Format && Format.length == 4)
@@ -158,13 +170,13 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
var oIMG = new ActiveXObject("SLNKDWF.ImageConvert");
try
{
oIMG.Open(params.AttachPath + result.safefilename);
oIMG.Open(params.AttachPath + result_safefilename);
}
catch(e)
{
result.message = L("lcl_shared_thumbnail_error") + e.description;
// Gewoon opruimen
DeleteFile(params.AttachPath + result.safefilename);
DeleteFile(params.AttachPath + result_safefilename);
}
var RrCc = Format[1];
@@ -183,7 +195,7 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
if (RrCc == "R" || RrCc == "C") // Dan zijn we streng en eisen we minimale afmeting
{
result.message = L("lcl_shared_photo_small").format(h0, w0, oIMG.Height, oIMG.Width);
DeleteFile(params.AttachPath + result.safefilename);
DeleteFile(params.AttachPath + result_safefilename);
}
else // Dan maar niet, we vergtoten niet.
{
@@ -197,13 +209,13 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
__Log("Resize/Cropping from w=" + oIMG.Width + " h=" + oIMG.Height + " to w=" + w + " h=" + h);
oIMG.Width = w;
oIMG.Height = h;
oIMG.SaveAs(params.AttachPath + result.safefilename);
oIMG.SaveAs(params.AttachPath + result_safefilename);
}
catch (e)
{
result.message = L("lcl_shared_thumbnail_error") + e.description;
// Gewoon opruimen
DeleteFile(params.AttachPath + result.safefilename);
DeleteFile(params.AttachPath + result_safefilename);
}
}
}
@@ -227,19 +239,19 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
oIMG.Height = maxThumbH;
}
CreateFullPath(params.AttachPath + "thumb/");
oIMG.SaveAs(params.AttachPath + "thumb/" + result.safefilename);
oIMG.SaveAs(params.AttachPath + "thumb/" + result_safefilename);
}
catch (e)
{
result.message = L("lcl_shared_thumbnail_error") + e.description;
DeleteFile(params.AttachPath + "thumb/" + result.safefilename);
DeleteFile(params.AttachPath + "thumb/" + result_safefilename);
}
break;
case "FGII":
// Direct scannen nu, indien dwf bestand. Tekening kan vaker gebruikt worden.
var sql = "SELECT cad_tekening_key"
+ " FROM cad_tekening"
+ " WHERE cad_tekening_filenaam || '.dwf' = " + safe.quoted_sql(result.safefilename);
+ " WHERE cad_tekening_filenaam || '.dwf' = " + safe.quoted_sql(result_safefilename);
var oRs = Oracle.Execute(sql);
while (!oRs.eof)
{
@@ -250,11 +262,15 @@ function jslog(str) // VB Vindt de twee underscores niet leuk
break;
}
}
}
%><script>
<% if (result.message) { %>
alert("<%=safe.jsstring(result.message)%>");
<% } %>
parent.uploadDone("<%=found_files[0].name%>"); // Zoo fout....
var JSONdata = "<%=safe.jsstring(JSON.stringify(result.safefilename))%>";
var filename_arr = eval('(' + JSONdata + ')');
parent.uploadDone(filename_arr); // Zoo fout....
</script>
<%
Response.End;
@@ -294,13 +310,6 @@ Public Function VB_getfiles()
Set UploadRequest = CreateObject("Scripting.Dictionary")
BuildUploadRequest RequestBin
' Dit moet nog ini een lus voor meerdere bestanden.
contentType = UploadRequest.Item("imgfile").Item("ContentType")
filepathname = UploadRequest.Item("imgfile").Item("FileName")
value = MultiByteToBinary(UploadRequest.Item("imgfile").Item("Value"))
js_add_file filepathname, value, contentType
result.add "safefilename", filepathname
' Vul via de (Javascipt) functie js_add_field de globale found_fields
' met de hidden form-fields uit de header
Dim ur_key, i, var_naam, var_waarde
@@ -309,6 +318,11 @@ Public Function VB_getfiles()
var_naam = ur_key(i)
if UploadRequest.Item(var_naam).Exists("ContentType") then
var_waarde = UploadRequest.Item(var_naam).Item("FileName")
' En dan nu nog de bestanden..
contentType = UploadRequest.Item(var_naam).Item("ContentType")
filepathname = UploadRequest.Item(var_naam).Item("FileName")
value = MultiByteToBinary(UploadRequest.Item(var_naam).Item("Value"))
js_add_file filepathname, value, contentType
else
var_waarde = UploadRequest.Item(var_naam).Item("Value")
end if

View File

@@ -9,6 +9,7 @@ Sub BuildUploadRequest(RequestBin)
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
boundary = MidB(RequestBin,PosBeg,PosEnd-PosBeg)
boundaryPos = InstrB(1,RequestBin,boundary)
img_nr = 1
'Get all data inside the boundaries
Do until (boundaryPos=InstrB(RequestBin,boundary & getByteString("--")))
'Members variable of objects are put in a dictionary object
@@ -30,6 +31,8 @@ Sub BuildUploadRequest(RequestBin)
FileName = getString(MidB(RequestBin,PosBeg,PosEnd-PosBeg))
'Add filename to dictionary object
UploadControl.Add "FileName", FileName
Name = Name & img_nr
img_nr = img_nr + 1
Pos = InstrB(PosEnd,RequestBin,getByteString("Content-Type:"))
PosBeg = Pos+14
PosEnd = InstrB(PosBeg,RequestBin,getByteString(chr(13)))
@@ -50,7 +53,7 @@ Sub BuildUploadRequest(RequestBin)
'Add content to dictionary object
UploadControl.Add "Value" , Value
'Add dictionary object to main dictionary
UploadRequest.Add name, UploadControl
UploadRequest.Add Name, UploadControl
'Loop to next object
BoundaryPos=InstrB(BoundaryPos+LenB(boundary),RequestBin,boundary)
Loop