0
votes

When I created a page on APEX 5 to upload a file the apex_application_temp_files is empty and its not letting me insert the file into my custom table.

I have this as my code

INSERT INTO custom_table(
     name,
     filename,
     mime_type,
     content,
     file_type,
     file_description,
     upload_by,
     upload_date)
     SELECT name, 
         filename,
         mime_type, 
         blob_content,
         :P1_FILETYPE,
         null,
         :APP_USER,
         sysdate
FROM apex_application_temp_files
WHERE 1=1
AND name = :P1_FILEBROWSER;

When I click my button the table doesn't have a value. I'm executing the pl/sql code on a dynamic action when the button UPLOAD is clicked.

I tried this to see if the dynamic action was working and it is, but I don't know how to get the filename, mime type and name from the file browser if there is nothing on the apex_application_temp_files table.

See the code that worked below but it doesn't get me the name, filename and mime type.

How can I fix this?

INSERT INTO custom_table(
     name,
     filename,
     mime_type,
     content,
     file_type,
     file_description,
     upload_by,
     upload_date)
     values ( 'name', 
     'filename',
     'mime',
     :P1_FILEBROWSER,
     :P1_FILETYPE,
         null,
         :APP_USER,
         sysdate
     );
1
I think you'll find the native file upload functionality needs a page submit, not a DA.Scott
Hello Scott, what if the problem is that I need to upload the file without a submit button? I guess if I can't do that I will do a whole submit of the page but can that be possible?GrumpyProgrammer
Then you may like to consider this apex.world/ords/…Scott

1 Answers

-1
votes

Please try the blow code

  for i in 1 .. v_arr.count
loop
    :p1_id := st_id.nextval;
    insert into custom_table(
                             id,
                             name,
                             content,
                             filename,
                             mime_type, 
                             file_type,
                             file_description,
                             upload_by,
                             upload_date)
    values (:p1_id, 
            (select name from apex_application_temp_files where name = v_arr(i)),
            (select blob_content from apex_application_temp_files where name = v_arr(i)),
            (select filename from apex_application_temp_files where name = v_arr(i)),
            (select mime_type from apex_application_temp_files where name = v_arr(i)),
            null,
            null,
            null,
            null
            );
end loop;