2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
\r
3 * Copyright (C) 2003-2010 Frederico Caldeira Knabben
\r
5 * == BEGIN LICENSE ==
\r
7 * Licensed under the terms of any of the following licenses at your
\r
10 * - GNU General Public License Version 2 or later (the "GPL")
\r
11 * http://www.gnu.org/licenses/gpl.html
\r
13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
\r
14 * http://www.gnu.org/licenses/lgpl.html
\r
16 * - Mozilla Public License Version 1.1 or later (the "MPL")
\r
17 * http://www.mozilla.org/MPL/MPL-1.1.html
\r
21 * Test page for the "File Uploaders".
\r
25 <title>FCKeditor - Uploaders Tests</title>
\r
26 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
\r
27 <script type="text/javascript">
\r
29 // Automatically detect the correct document.domain (#1919).
\r
32 var d = document.domain ;
\r
36 // Test if we can access a parent property.
\r
39 var test = window.opener.document.domain ;
\r
44 // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
\r
45 d = d.replace( /.*?(?:\.|$)/, '' ) ;
\r
47 if ( d.length == 0 )
\r
48 break ; // It was not able to detect the domain.
\r
52 document.domain = d ;
\r
63 var sUploaderUrl = cmbUploaderUrl.value ;
\r
65 if ( sUploaderUrl.length == 0 )
\r
66 sUploaderUrl = txtCustomUrl.value ;
\r
68 if ( sUploaderUrl.length == 0 )
\r
70 alert( 'Please provide your custom URL or select a default one' ) ;
\r
74 eURL.innerHTML = sUploaderUrl ;
\r
77 var date = new Date()
\r
79 frmUpload.action = sUploaderUrl + '?time=' + date.getTime();
\r
80 if (document.getElementById('cmbType').value) {
\r
81 frmUpload.action = frmUpload.action + '&Type='+document.getElementById('cmbType').value;
\r
83 if (document.getElementById('CurrentFolder').value) {
\r
84 frmUpload.action = frmUpload.action + '&CurrentFolder='+document.getElementById('CurrentFolder').value;
\r
86 frmUpload.submit() ;
\r
89 function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
\r
91 switch ( errorNumber )
\r
93 case 0 : // No errors
\r
94 txtUrl.value = fileUrl ;
\r
95 alert( 'File uploaded with no errors' ) ;
\r
97 case 1 : // Custom error
\r
98 alert( customMsg ) ;
\r
100 case 10 : // Custom warning
\r
101 txtUrl.value = fileUrl ;
\r
102 alert( customMsg ) ;
\r
105 txtUrl.value = fileUrl ;
\r
106 alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
\r
109 alert( 'Invalid file' ) ;
\r
112 alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
\r
115 alert( 'Error on file upload. Error number: ' + errorNumber ) ;
\r
123 <table cellSpacing="0" cellPadding="0" width="100%" border="0" height="100%">
\r
126 <table cellSpacing="0" cellPadding="0" width="100%" border="0">
\r
129 Select the "File Uploader" to use: <br>
\r
130 <select id="cmbUploaderUrl">
\r
131 <option selected value="asp/upload.asp">ASP</option>
\r
132 <option value="aspx/upload.aspx">ASP.Net</option>
\r
133 <option value="cfm/upload.cfm">ColdFusion</option>
\r
134 <option value="lasso/upload.lasso">Lasso</option>
\r
135 <option value="perl/upload.cgi">Perl</option>
\r
136 <option value="php/upload.php">PHP</option>
\r
137 <option value="py/upload.py">Python</option>
\r
138 <option value="">(Custom)</option>
\r
142 Resource Type<br />
\r
143 <select id="cmbType" name="cmbType">
\r
144 <option value="">None</option>
\r
145 <option value="File">File</option>
\r
146 <option value="Image">Image</option>
\r
147 <option value="Flash">Flash</option>
\r
148 <option value="Media">Media</option>
\r
149 <option value="Invalid">Invalid Type (for testing)</option>
\r
153 Current Folder: <br>
\r
154 <input type="text" name="CurrentFolder" id="CurrentFolder" value="/">
\r
156 <td nowrap> </td>
\r
158 Custom Uploader URL:<BR>
\r
159 <input id="txtCustomUrl" style="WIDTH: 100%; BACKGROUND-COLOR: #dcdcdc" disabled type="text">
\r
164 <table cellSpacing="0" cellPadding="0" width="100%" border="0">
\r
167 <form id="frmUpload" target="UploadWindow" enctype="multipart/form-data" action="" method="post">
\r
168 Upload a new file:<br>
\r
169 <input type="file" name="NewFile"><br>
\r
171 <input type="button" value="Send it to the Server" onclick="SendFile();">
\r
174 <td style="WIDTH: 16px"> </td>
\r
175 <td vAlign="top" width="100%">
\r
176 Uploaded File URL:<br>
\r
177 <INPUT id="txtUrl" style="WIDTH: 100%" readonly type="text">
\r
182 Post URL: <span id="eURL"> </span>
\r
187 <iframe name="UploadWindow" width="100%" height="100%" src="javascript:void(0)"></iframe>
\r