1 <SCRIPT TYPE="text/javascript">
3 function doUpload(form, callback) {
4 var name = 'form' + Math.floor(Math.random() * 99999); // perlize?
5 var d = document.createElement('DIV');
6 d.innerHTML = '<iframe style="display:none" src="about:blank" ' +
8 'name="' + name + '" ' +
9 'onload="uploadComplete(\'' + name + '\')">' +
11 document.body.appendChild(d);
13 var i = document.getElementById(name);
14 if (callback && typeof(callback) == 'function') {
15 i.onComplete = callback;
18 form.setAttribute('target', name);
22 function uploadComplete(id) {
23 var i = document.getElementById(id);
24 if (i.contentDocument) {
25 var d = i.contentDocument;
26 } else if (i.contentWindow) {
27 var d = i.contentWindow.document;
29 var d = window.frames[id].document;
31 if (d.location.href == "about:blank") {
35 document.getElementById('r').innerHTML = d.body.innerHTML;
36 if (typeof(i.onComplete) == 'function') {
38 if (p = d.body.innerHTML.indexOf("File Upload Successful ") >= 0) {
39 var v = d.body.innerHTML.substr(p+24);
40 var u = document.getElementById('uploaded_files');
41 v = v.substr(0, v.indexOf(';'));
43 i.onComplete(true, '');
45 i.onComplete(false, d.body.innerHTML);
52 <INPUT TYPE="hidden" NAME="uploaded_files" ID="uploaded_files" VALUE="" />
54 <INPUT TYPE="hidden" NAME="upload_fields" VALUE="<% join(',', @field) %>" />
57 % if($param{'no_table'}) {
58 <% shift @label %> <INPUT TYPE="file" NAME="<% $_ %>" />
62 <TH ALIGN="<% $param{'label_align'} || 'right' %>"><% shift @label %></TH>
63 <TD><INPUT TYPE="file" NAME="<% $_ %>" /></TD>
68 <DIV STYLE="display:<% $param{debug} ? 'visible' : 'none' %>">
69 Debugging: <PRE ID="r"></PRE>
76 my @label = ref($param{'label'}) ? @{$param{'label'}} : ($param{'label'});
77 my @field = ref($param{'field'}) ? @{$param{'field'}} : ($param{'field'});