Thursday, November 30, 2006

 

Multifile upload

Procedure to upload multi files. Using solution from http://www.the-stickman.com.

procedure DocumentUploadMulti (
name_array in owa.vc_arr,
value_array in owa.vc_arr)
is
pdatoteka Documents.name%type;
FUNCTION namedParam(
p_searchVal in varchar2,
p_name_array in owa.vc_arr,
p_value_array in owa.vc_arr
) RETURN varchar2 IS
i integer;
BEGIN
FOR i IN 1..nvl(p_name_array.count,0) LOOP
if p_name_array(i)=p_searchVal then
return p_value_array(i);
end if;
END LOOP;
return null;
END;
begin
pdatoteka := namedParam('pdatoteka',name_array,value_array);
htp.p('
<html>
<HEAD>
<META HTTP-EQUIV="Content-Type" NAME="" CONTENT="text/html;CHARSET=WINDOWS-1250">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<SCRIPT LANGUAGE="JavaScript">
// Multiple file selector by Stickman
-- http://www.the-stickman.com
// with thanks to: [for Safari fixes] Luis Torrefranca
-- http://www.law.pitt.edu and Shawn Parker & John Pennypacker
-- http://www.fuzzycoconut.com [for duplicate name bug] ''neal''
function MultiSelector( list_target, max ){
this.list_target = list_target;
this.count = 0;
this.id = 0;
if( max ){this.max = max;}
else {this.max = -1;};
this.addElement = function( element ){
if( element.tagName == ''INPUT'' && element.type == ''file'' ){
element.name = ''file_'' + this.id++;element.multi_selector = this;element.onchange = function(){
var new_element = document.createElement( ''input'' );
new_element.type = ''file'';
this.parentNode.insertBefore( new_element, this );
this.multi_selector.addElement( new_element );
this.multi_selector.addListRow( this );
this.style.position = ''absolute'';
this.style.left = ''-1000px'';};
if( this.max != -1 && this.count >= this.max ){
element.disabled = true;};
this.count++;this.current_element = element;}
else {alert( ''Error: not a file input element'' );};};
this.addListRow = function( element ){
var new_row = document.createElement( ''div'' );
var new_row_button = document.createElement( ''input'' );
new_row_button.type = ''button'';new_row_button.value = ''Delete'';
new_row.element = element;new_row_button.onclick= function(){
this.parentNode.element.parentNode.removeChild( this.parentNode.element );
this.parentNode.parentNode.removeChild( this.parentNode );
this.parentNode.element.multi_selector.count--;
this.parentNode.element.multi_selector.current_element.disabled = false;
return false;};
new_row.innerHTML = element.value;
new_row.appendChild( new_row_button );
this.list_target.appendChild( new_row );};
};
</SCRIPT>
<title>Upload</title>
</HEAD>
<body>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFF99" summary="">
<tr><td><font size="5">Upload</font></TD></TR>
</TABLE>');
if pdatoteka is not null then
htp.p('
<BR> File "'substr(pdatoteka, instr(pdatoteka,'/',-1,1)+1
)'" is uploaded. <BR>');
else
htp.p('
<FORM enctype="multipart/form-data" action="!dd_lib.DocumentUploadMulti" method="POST">
<p>File:<INPUT type="file" id="my_file_element" name="pdatoteka"></p>
<p><INPUT type="submit" class=submit value="Submit" ></p>
</FORM>
Files:
<!-- This is where the output will appear -->
<div id="files_list"></div>
<script>
<!-- Create an instance of the multiSelector class, pass it the output target and the max number of files -->
var multi_selector = new MultiSelector( document.getElementById( ''files_list'' ), 200 );
<!-- Pass in the file element -->
multi_selector.addElement( document.getElementById( ''my_file_element'' ) );
</script>
<BR>');
end if;
htp.p('
</body>
</html>');
exception when others then
htp.p('
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=WINDOWS-1250">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<TITLE>Message</TITLE>
</HEAD>
<BODY bgcolor="#C0C0C0">');
htp.p('
<table>
<tr><td><FONT COLOR="red" size="4">Error: </FONT></td>
<td>'replace(sqlerrm,'','<BR>')'</td>
</tr>
</table>
<BR>
<INPUT TYPE="button" VALUE="Back" class=submit onClick="javascript:history.go(-1)">
</BODY>
</HTML>');
end;

Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?