如何调用AJAX回调上传文件?

问题描述 投票:0回答:0

我正在尝试通过 ajax 回调(数组缓冲区)上传文件,当文件大小约为 6MB 时它工作正常,但当文件大小约为 10MB 时出现此错误

POST http://localhost:90/ords/wwv_flow.ajax 500

我正在尝试通过以下代码:-

  apex.server.process(
      'UPLOAD_FILE',
      {
        x01: "test",
        x02: "application/pdf",
        f01: f01Array
      },
      {
        dataType: 'json',
        success: function(data) {
           if (data.result == 'success') {
           // apex.event.trigger( "#CLD", "apexrefresh" );
           
            apex.submit( 'APPROVE' );               
           }
               else {
                     alert('Oops! Something went terribly wrong. Please try again or contact your application administrator.');
               }
                
           }
        }
      
    );

f01Array 表示文件。 以下代码用于 ajax 回调

declare
  l_blob blob;
  l_filename varchar2(200);
  l_mime_type varchar2(200);
  l_token varchar2(32000);

begin 
  l_filename := apex_application.g_x01;
  l_mime_type := apex_application.g_x02;
 
  -- build BLOB from f01 30k array (base64 encoded)
  dbms_lob.createtemporary(l_blob, false, dbms_lob.session);
  for i in 1 .. apex_application.g_f01.count loop
    l_token := wwv_flow.g_f01(i);
    if length(l_token) > 0 then
      dbms_lob.append(
        dest_lob => l_blob,
        src_lob => to_blob(utl_encode.base64_decode(utl_raw.cast_to_raw(l_token)))
      );
    end if;
  end loop;
 
  -- add collection member (only if BLOB is not null)
  if dbms_lob.getlength(l_blob) is not null then
    apex_collection.add_member(
      p_collection_name => 'UPLOADED_FILES',
      p_c001 => l_filename,
      p_c002 => l_mime_type,
      p_blob001 => l_blob
    );
  end if;
 
  apex_json.open_object;
  apex_json.write(
    p_name => 'result',
    p_value => 'success'
  );
  apex_json.close_object;
exception
  when others then
    apex_json.open_object;
    apex_json.write(
      p_name => 'result',
      p_value => 'fail'
    );
    apex_json.close_object;
end;

环境

apex version 19.2 
tomcat 8.5 ,
ords

           
                   
oracle plsql blob oracle-apex
© www.soinside.com 2019 - 2024. All rights reserved.