Project

General

Profile

1
<!--
2
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
3
 * Copyright (C) 2003-2009 Frederico Caldeira Knabben
4
 *
5
 * == BEGIN LICENSE ==
6
 *
7
 * Licensed under the terms of any of the following licenses at your
8
 * choice:
9
 *
10
 *  - GNU General Public License Version 2 or later (the "GPL")
11
 *    http://www.gnu.org/licenses/gpl.html
12
 *
13
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14
 *    http://www.gnu.org/licenses/lgpl.html
15
 *
16
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
17
 *    http://www.mozilla.org/MPL/MPL-1.1.html
18
 *
19
 * == END LICENSE ==
20
 *
21
 * Test page for the "File Uploaders".
22
-->
23
<html>
24
	<head>
25
		<title>FCKeditor - Uploaders Tests</title>
26
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
27
		<script type="text/javascript">
28

    
29
// Automatically detect the correct document.domain (#1919).
30
(function()
31
{
32
	var d = document.domain ;
33

    
34
	while ( true )
35
	{
36
		// Test if we can access a parent property.
37
		try
38
		{
39
			var test = window.opener.document.domain ;
40
			break ;
41
		}
42
		catch( e ) {}
43

    
44
		// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
45
		d = d.replace( /.*?(?:\.|$)/, '' ) ;
46

    
47
		if ( d.length == 0 )
48
			break ;		// It was not able to detect the domain.
49

    
50
		try
51
		{
52
			document.domain = d ;
53
		}
54
		catch (e)
55
		{
56
			break ;
57
		}
58
	}
59
})() ;
60

    
61
function SendFile()
62
{
63
	var sUploaderUrl = cmbUploaderUrl.value ;
64

    
65
	if ( sUploaderUrl.length == 0 )
66
		sUploaderUrl = txtCustomUrl.value ;
67

    
68
	if ( sUploaderUrl.length == 0 )
69
	{
70
		alert( 'Please provide your custom URL or select a default one' ) ;
71
		return ;
72
	}
73

    
74
	eURL.innerHTML = sUploaderUrl ;
75
	txtUrl.value = '' ;
76

    
77
	var date = new Date()
78

    
79
	frmUpload.action = sUploaderUrl + '?time=' + date.getTime();
80
	if (document.getElementById('cmbType').value) {
81
		frmUpload.action = frmUpload.action + '&Type='+document.getElementById('cmbType').value;
82
	}
83
	if (document.getElementById('CurrentFolder').value) {
84
		frmUpload.action = frmUpload.action + '&CurrentFolder='+document.getElementById('CurrentFolder').value;
85
	}
86
	frmUpload.submit() ;
87
}
88

    
89
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
90
{
91
	switch ( errorNumber )
92
	{
93
		case 0 :	// No errors
94
			txtUrl.value = fileUrl ;
95
			alert( 'File uploaded with no errors' ) ;
96
			break ;
97
		case 1 :	// Custom error
98
			alert( customMsg ) ;
99
			break ;
100
		case 10 :	// Custom warning
101
			txtUrl.value = fileUrl ;
102
			alert( customMsg ) ;
103
			break ;
104
		case 201 :
105
			txtUrl.value = fileUrl ;
106
			alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
107
			break ;
108
		case 202 :
109
			alert( 'Invalid file' ) ;
110
			break ;
111
		case 203 :
112
			alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
113
			break ;
114
		default :
115
			alert( 'Error on file upload. Error number: ' + errorNumber ) ;
116
			break ;
117
	}
118
}
119

    
120
		</script>
121
	</head>
122
	<body>
123
		<table cellSpacing="0" cellPadding="0" width="100%" border="0" height="100%">
124
			<tr>
125
				<td>
126
					<table cellSpacing="0" cellPadding="0" width="100%" border="0">
127
						<tr>
128
							<td nowrap>
129
								Select the "File Uploader" to use: <br>
130
								<select id="cmbUploaderUrl">
131
									<option selected value="asp/upload.asp">ASP</option>
132
									<option value="aspx/upload.aspx">ASP.Net</option>
133
									<option value="cfm/upload.cfm">ColdFusion</option>
134
									<option value="lasso/upload.lasso">Lasso</option>
135
									<option value="perl/upload.cgi">Perl</option>
136
									<option value="php/upload.php">PHP</option>
137
									<option value="py/upload.py">Python</option>
138
									<option value="">(Custom)</option>
139
								</select>
140
							</td>
141
						<td>
142
							Resource Type<br />
143
							<select id="cmbType" name="cmbType">
144
								<option value="">None</option>
145
								<option value="File">File</option>
146
								<option value="Image">Image</option>
147
								<option value="Flash">Flash</option>
148
								<option value="Media">Media</option>
149
								<option value="Invalid">Invalid Type (for testing)</option>
150
							</select>
151
						</td>
152
						<td>
153
						Current Folder: <br>
154
						<input type="text" name="CurrentFolder" id="CurrentFolder" value="/">
155
						</td>
156
							<td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
157
							<td width="100%">
158
								Custom Uploader URL:<BR>
159
								<input id="txtCustomUrl" style="WIDTH: 100%; BACKGROUND-COLOR: #dcdcdc" disabled type="text">
160
							</td>
161
						</tr>
162
					</table>
163
					<br>
164
					<table cellSpacing="0" cellPadding="0" width="100%" border="0">
165
						<tr>
166
							<td noWrap>
167
								<form id="frmUpload" target="UploadWindow" enctype="multipart/form-data" action="" method="post">
168
									Upload a new file:<br>
169
									<input type="file" name="NewFile"><br>
170

    
171
									<input type="button" value="Send it to the Server" onclick="SendFile();">
172
								</form>
173
							</td>
174
							<td style="WIDTH: 16px">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
175
							<td vAlign="top" width="100%">
176
								Uploaded File URL:<br>
177
								<INPUT id="txtUrl" style="WIDTH: 100%" readonly type="text">
178
							</td>
179
						</tr>
180
					</table>
181
					<br>
182
					Post URL: <span id="eURL">&nbsp;</span>
183
				</td>
184
			</tr>
185
			<tr>
186
				<td height="100%">
187
					<iframe name="UploadWindow" width="100%" height="100%" src="javascript:void(0)"></iframe>
188
				</td>
189
			</tr>
190
		</table>
191
	</body>
192
</html>
(4-4/5)