Upload Multiple files into table code

Oracle Application Express is a rapid development tool for Web applications on the Oracle database.
Post Reply
admin
Posts: 2062
Joined: Fri Mar 31, 2006 12:59 am
Location: Pakistan
Contact:

Upload Multiple files into table code

Post by admin »

CREATE TABLE ERPSTUFF_FILES
( ID NUMBER,
PROJECT_ID NUMBER,
FILENAME VARCHAR2(255),
FILE_MIMETYPE VARCHAR2(512),
FILE_CHARSET VARCHAR2(512),
FILE_BLOB BLOB,
FILE_COMMENTS VARCHAR2(500),
TAGS VARCHAR2(500),
CREATED TIMESTAMP (6),
CREATED_BY VARCHAR2(255),
UPDATED TIMESTAMP (6),
UPDATED_BY VARCHAR2(255),
CONSTRAINT ERPSTUFF_FILES_PK PRIMARY KEY (ID)
USING INDEX ENABLE
)

Single File
begin
for c1 in (select *
from apex_application_temp_files
where name = :P13_FILE)
loop
insert into eba_demo_files (
project_id,
filename,
file_blob,
file_comments,
file_mimetype)
values (
:P13_ID,
c1.filename,
c1.blob_content,
:P13_FILE_DESCRIPTION,
c1.mime_type);
end loop;

:P13_FILE_DESCRIPTION := null;
:P13_FILE := null;
end;

Multiple Files
create table erpstuff_files (name VARCHAR2(400), filename VARCHAR2(400), mime_type VARCHAR2(255), created_on date, blob_content blob);

declare
l_file_names apex_t_varchar2;
l_file apex_application_temp_files%rowtype;
begin
l_file_names := apex_string.split (
p_str => :P2_DOC,
p_sep => ':' );
for i in 1 .. l_file_names.count loop
select *
into l_file
from apex_application_temp_files
where name = l_file_names(i);

insert into ERPSTUFF_FILES (PROJECT_ID, FILENAME , FILE_MIMETYPE , CREATED , FILE_BLOB )
values
(:PROJECT_ID , l_file.name, l_file.filename , l_file.mime_type , l_file.created_on , l_file.blob_content);
end loop;
end;

Purge File at
Define when Oracle APEX should remove the temporary file.

Available options include:

End of Session
Delete the file at the end of the current Oracle APEX session.
End of Request
Delete the file at the end of the current HTTP request.

select
ID,
NAME,
dbms_lob.getlength(file_blob)) file_size,
dbms_lob.getlength(file_blob) image
from ERPSTUFF_FILES

if updating and :NEW.ICON_NAME is not null and nvl(dbms_lob.getlength(:NEW.ICON_BLOB),0) > 204800 then
raise_application_error(-20000, 'The size of the uploaded icon image was over 200kb. Please upload a smaller sized image.');
end if;
-- Mimetype (must be image)
if (inserting or updating) and :NEW.ICON_NAME is not null and nvl(:NEW.ICON_MIMETYPE,'NULL') not like 'image%' then
raise_application_error(-20000, 'The uploaded file was not an image. Please upload an image file.');
end if;

VIDEO
Malik Sikandar Hayat
admin@erpstuff.com
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests