Koden:
<!--#include file="common.asp" -->
<!--#include file="functions/functions_upload.asp" -->
<%
'Set the timeout of the page
Server.ScriptTimeout = 1000
'Set the response buffer to true as we maybe redirecting
Response.Buffer = True
'Declare variables
Dim strErrorMessage 'Holds the error emssage if the file is not uploaded
Dim lngErrorFileSize 'Holds the file size if the file is not saved because it is to large
Dim blnExtensionOK 'Set to false if the extension of the file is not allowed
Dim strMessageBoxType 'Holds the type of message box used RTE or basic
Dim strImageName 'Holds the file name
Dim saryFileUploadTypes 'Holds the array of file to upload
'Intiliase variables
blnExtensionOK = True
'read in the message box type
strMessageBoxType = Request.QueryString("MSG")
'If this is a post back then upload the image
If Request.QueryString("PB") = "Y" Then
'Get the image types to upload
saryFileUploadTypes = Split(Trim(strImageTypes), ";")
'Call upoload file function
strImageName = fileUpload(strFileUploadPath, saryFileUploadTypes, intMaxImageSize, strUploadComponent, lngErrorFileSize, blnExtensionOK)
End If
%>
<html>
<head>
<meta name="copyright" content="Copyright (C) 2002-2004 Bruce Corkhill" />
<title>Image Upload</title>
<!-- Web Wiz Rich Text Editor ver. <% = strRTEversion %> is written and produced by Bruce Corkhill ©2002-2004
If you want your own Rich Text Editor then goto
http://www.richtexteditor.org -->
<script language="JavaScript">
<%
'If the image has been saved then place it in the post
If lngErrorFileSize = 0 AND blnExtensionOK = True AND strImageName <> "" Then
'If this is Rich text editor and IE5.0 use the exeCommand to place it in the editor
If strMessageBoxType = "RTE" AND RTEenabled = "winIE5" Then
%>
window.opener.frames.message.document.focus();
window.opener.frames.message.document.execCommand('InsertImage', false, '<% = strFileUploadPath & "/" & strImageName %>');
window.close();
<%
'If this is Rich text editor use the exeCommand to place it in the editor
ElseIf strMessageBoxType = "RTE" Then
%>
window.opener.document.getElementById("message").contentWindow.focus();
window.opener.document.getElementById("message").contentWindow.document.execCommand('InsertImage', false, '<% = strFileUploadPath & "/" & strImageName %>');
window.close();
<%
'Else if they are using the basic editor place the image path into it
ElseIf strMessageBoxType = "BSC" Then
%>
window.opener.document.frmAddMessage.message.focus();
window.opener.document.frmAddMessage.message.value += '<img src="<% = strFileUploadPath & "/" & strImageName %>" />';
window.close();
<%
End If
End If
%>
</script>
<style type="text/css">
<!--
html, body {
background: ButtonFace;
color: ButtonText;
font: font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
margin: 1px;
padding: 3px;
}
legend {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #0000FF;
}
-->
</style>
<link href="includes/default_style.css" rel="stylesheet" type="text/css" />
</head>
<body OnLoad="self.focus(); document.forms.frmImageUp.Submit.disabled=true;"><%
'If the user is allowed to upload then show them the form
If blnImageUpload Then
%>
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="0">
<form action="upload_images.asp?MSG=<% = strMessageBoxType %>&PB=Y" method="post" enctype="multipart/form-data" name="frmImageUp" target="_self" id="frmImageUp" onSubmit="alert('<% = strTxtPleaseWaitWhileImageIsUploaded %>')">
<tr>
<td width="100%">
<fieldset>
<legend><% = strTxtImageUpload %></legend>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<td width="10%" align="right" class="text"><% = strTxtImage %>:</td>
<td width="90%"><input name="file" type="file" size="35" onFocus="document.forms.frmImageUp.Submit.disabled=false;" onChange="document.forms.frmImageUp.Submit.disabled=false;" />
</td>
</tr>
<tr align="center">
<td colspan="2" class="text"><br /><%
'If the file upload has failed becuase of the wrong extension display an error message
If blnExtensionOK = False Then
Response.Write("<span class=""error"">" & strTxtImageOfTheWrongFileType & ".<br />" & strTxtImagesMustBeOfTheType & ", " & Replace(strImageTypes, ";", ", ", 1, -1, 1) & "</span>")
'Else if the file upload has failed becuase the size is to large display an error message
ElseIf lngErrorFileSize <> 0 Then
Response.Write("<span class=""error"">" & strTxtImageFileSizeToLarge & " " & lngErrorFileSize & "KB.<br />" & strTxtMaximumFileSizeMustBe & " " & intMaxImageSize & "KB</span>")
'Else display a message of the image types that can be uploaded
Else
Response.Write(strTxtImagesMustBeOfTheType & ", " & Replace(strImageTypes, ";", ", ", 1, -1, 1) & ", " & strTxtAndHaveMaximumFileSizeOf & " " & intMaxImageSize & "KB")
End If
%></td>
</tr>
</table>
</fieldset></td>
</tr>
<tr align="right">
<td> <input type="submit" name="Submit" value=" <% = strTxtOK %> "> <input type="button" name="cancel" value=" <% = strTxtCancel %> " onClick="window.close()"></td>
</tr>
</form>
</table><%
End If
%>
</body>
</html>