File: D:/HostingSpaces/RImmers/duitsedog.tk/wwwroot/onderhoud/wijzig_foto.asp
<%
option explicit
Response.Expires = -1
Server.ScriptTimeout = 600
%>
<!-- #INCLUDE VIRTUAL="/includes/inc_default.asp" -->
<!-- #INCLUDE VIRTUAL="/includes/inc_auth.asp" -->
<%
Const uploadsDirVar = "D:\HostingSpaces\RImmers\duitsedog.tk\wwwroot\fotos"
Const intMaxBytes = 1024000
Dim Conn, Rs, strSql, strMsg, MyFile, i, objFSO, Upload, ks, fileKey, strFileNamePath, intAantalBytes, strBody, objMail, _
intId, intTypeId, intSeizoenId, strOms, strBestandsnaam, blnActief
If Request.ServerVariables("CONTENT_LENGTH") <> 0 Then
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set Upload = New FreeASPUpload
Upload.Save(uploadsDirVar)
intId = FormToInt(Upload.Form("txtId"))
intTypeId = FormToInt(Upload.Form("selTypes"))
intSeizoenId = FormToInt(Upload.Form("selSeizoenen"))
intAantalBytes = FormToInt(Upload.Form("txtAantalBytes"))
strOms = FormToStr(Upload.Form("txtOms"))
blnActief = Upload.Form("cbActief") <> ""
ks = Upload.UploadedFiles.keys
if (UBound(ks) <> -1) then
for each fileKey in Upload.UploadedFiles.keys
strBestandsnaam = Upload.UploadedFiles(fileKey).FileName
intAantalBytes = Upload.UploadedFiles(fileKey).Length
next
' Set MyFile = objFSO.GetFile(uploadsDirVar & strBestandsnaam)
' If intAantalBytes >= intMaxBytes Then
' MyFile.Delete
' strMsg = "Bestand is groter dan de toegestane grootte!"
' Else
strFileNamePath = uploadsDirVar & "\" & FotoTypeOms(intTypeId)
Call objFSO.MoveFile(uploadsDirVar & "\" & strBestandsnaam, strFileNamePath & "\" & strBestandsnaam)
' End If
Else
strBestandsnaam = FormToStr(Upload.Form("txtBestandsnaam"))
End If
If IsNull(intId) Then
intId = InsertFoto(intSeizoenId,intTypeId,strOms,strBestandsnaam,intAantalBytes,blnActief)
Else
Call UpdateFoto(intId,intSeizoenId,intTypeId,strOms,strBestandsnaam,intAantalBytes,blnActief)
End If
strMsg = "Foto '" & strOms & "' opgeslagen. (" & intAantalBytes & " bytes)"
Response.Redirect("fotos.asp?type_id=" & intTypeId & "&msg=" & strMsg)
Response.Flush
Response.End
Set objFSO = Nothing
Set MyFile = Nothing
Else
If Request.QueryString("id") <> "" Then
intId = FormToInt(Request.QueryString("id"))
Set Rs = GetRs("SELECT * FROM DD_FOTOS WHERE id = " & IntToSQL(intId))
If Not Rs.EOF Then
intTypeId = SqlToInt(Rs("type_id"))
intSeizoenId = SqlToInt(Rs("seizoen_id"))
strOms = SqlToStr(Rs("oms"))
strBestandsnaam = SqlToStr(Rs("bestandsnaam"))
intAantalBytes = SqlToInt(Rs("grootte"))
blnActief = SqlToBool(Rs("ind_actief"))
End If
strMsg = Null
else
intId = Null
intTypeId = Null
' 21-3 = lente
' 21-6 = zomer
' 23-9 = herfst
' 22-12 = winter
If (Month(date)=3 And Day(date)>=21) Or (Month(date)>3 And Month(date)<=6 And Day(date)<21)Then
intSeizoenId = 1
ElseIf (Month(date)=6 And Day(date)>=21) Or (Month(date)>6 And Month(date)<=9 And Day(date)<23)Then
intSeizoenId = 2
ElseIf (Month(date)=9 And Day(date)>=23) Or (Month(date)>9 And Month(date)<=12 And Day(date)<22)Then
intSeizoenId = 3
Else
intSeizoenId = 4
End If
strOms = Null
strBestandsnaam = Null
intAantalBytes = Null
blnActief = True
End If
End If
%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/onderhoud.css">
<script language="JavaScript">
function doCheck(){
if(!document.form1.txtOms.value){
alert('Geen omschrijving ingevoerd!');
document.form1.txtOms.focus();
return false;
}
else if(!document.form1.selTypes.value){
alert('Geen type geselecteerd!');
document.form1.selTypes.focus();
return false;
}
else {
return true;
}
}
</script>
</head>
<body>
<h2>Foto upload</h2>
<%
If strMsg<>"" Then Response.Write("<p><b>" & strMsg & "</b></p>") End If
%>
<form id="form1" name="form1" action="wijzig_foto.asp" enctype="multipart/form-data" method="post" onsubmit="document.form1.cmdSave.disabled=true;">
<input type="hidden" name="txtId" value="<%=intId%>">
<input type="hidden" name="txtBestandsnaam" value="<%=strBestandsnaam%>">
<input type="hidden" name="txtAantalBytes" value="<%=intAantalBytes%>">
<table>
<tr>
<td><b>Actief</b></td>
<td><input type="checkbox" name="cbActief" <%If blnActief Then %>checked<%End If%>></td>
</tr>
<tr>
<td valign="top"><b>Bestand</b></td>
<td>
<%
If Not IsNull(strBestandsnaam) Then
%>
<!-- <div align="center"><img id="preview" border="0" title="Duitse dog pup" src="/fotos/<%=FotoTypeOms(intTypeId) & "/" & strBestandsnaam%>"/></div>-->
<div><img border="0" title="Duitse dog pup" src="Resize_Image.aspx?ImgWd=400&CrpYN=Y&IptFl=/fotos/<%=FotoTypeOms(intTypeId) & "/" & strBestandsnaam%>"/></div>
<%
End If
%>
</td>
<tr>
<tr>
<td> </td>
<td><input type="file" style="height=20" name="txtFoto" size="70" value=""></td>
<tr>
<tr>
<td valign="top"><b>Type</b></td>
<td>
<select name="selTypes">
<option value="">- Selecteer -</option>
<%
Set Rs = GetRs("select * from DD_FOTO_TYPES")
While Not Rs.EOF
%>
<option <%If intTypeId = Rs("id") Then Response.Write("selected")%> value="<%=Rs("id")%>"><%=Rs("oms") & " (" & Rs("afm") & ")"%></option>
<%
Rs.MoveNext
Wend
Rs.Close
%>
</select>
<td>
</tr>
<tr>
<td valign="top"><b>Seizoen</b></td>
<td>
<select name="selSeizoenen">
<option value="">- Selecteer -</option>
<%
Set Rs = GetRs("select * from DD_FOTO_SEIZOENEN")
While Not Rs.EOF
%>
<option <%If intSeizoenId = Rs("id") Then Response.Write("selected")%> value="<%=Rs("id")%>"><%=Rs("oms")%></option>
<%
Rs.MoveNext
Wend
Rs.Close
%>
</select>
<td>
</tr>
<tr>
<td><b>Omschrijving</b></td>
<td><input type="text" name="txtOms" size="50" value="<%=strOms%>"></td>
<tr>
</table>
<p>
<input type="submit" style="width:100;height=20" name="cmdSave" value="Opslaan" class="clsBtn" onclick="return doCheck();">
<input type="button" style="width:100;height=20" value="Annuleren" onclick="document.location.href='fotos.asp?type_id=<%=intTypeId%>';" id=button1 name=button1>
</p>
</form>
</body>
</html>