public final boolean uploadFile(String iusername, String ibranch, String idocdate, String doculink_str,
	String docustatus_str,String ftitle, String fdesc) throws SQLException,InterruptedException,IOException
{
	org.zkoss.util.media.Media uploaded_file = org.zkoss.zul.Fileupload.get(true);
	
	if(uploaded_file == null) return false;
	
	String formatstr = uploaded_file.getFormat();
	String contenttype = uploaded_file.getContentType();
	String ufilename = uploaded_file.getName();
	
	Object uploaded_data;
	int fileLength = 0;
	
	boolean f_inmemory = uploaded_file.inMemory();
	boolean f_isbinary = uploaded_file.isBinary();
	
	if(f_inmemory && f_isbinary)
	{
		byte[] tmp_uploaded_data = uploaded_file.getByteData();
		uploaded_data = tmp_uploaded_data;
	}
	else
	{
		InputStream tmp_uploaded_data = uploaded_file.getStreamData();
		fileLength = tmp_uploaded_data.available();
		uploaded_data = tmp_uploaded_data;
	}

	if(uploaded_data == null)
	{
		guihand.showMessageBox("Invalid file-type uploaded..");
		return false;
	}

	// alert("formatstr: " + formatstr + " | contenttype: " + contenttype + " | filename: " + ufilename);

	Sql ds_sql = DMS_Sql();
	if(ds_sql == null) return false;
	Connection thecon = ds_sql.getConnection();

	PreparedStatement pstmt = thecon.prepareStatement("insert into DocumentTable(file_title,file_description,docu_link,docu_status,username,datecreated,version," +
		"file_name,file_type,file_extension,file_data,deleted,branch) values (?,?,?,?,?,?,?,?,?,?,?,?,?)");

	pstmt.setString(1, ftitle);
	pstmt.setString(2, fdesc);
	pstmt.setString(3, doculink_str);
	pstmt.setString(4, docustatus_str);
	pstmt.setString(5, iusername);
	pstmt.setString(6,idocdate);
	pstmt.setInt(7,1);
	pstmt.setString(8,ufilename);
	pstmt.setString(9,contenttype);
	pstmt.setString(10,formatstr);

	if(f_inmemory && f_isbinary)
		pstmt.setBytes(11, (byte[])uploaded_data);
	else
		pstmt.setBinaryStream(11, (InputStream)uploaded_data, fileLength);

	pstmt.setInt(12,0); // deleted flag
	pstmt.setString(13, ibranch);

	pstmt.executeUpdate();
	ds_sql.close();

	return true;
}