像往常一樣的結構,有親和禁忌兩個選項:保持圖像的數據庫,或者讓他們在一個文件系統。在我看來,如果只有幾個(好吧,讓我們來測量它們在100秒內),我寧願把它們放在桌子上。處理它們更容易。因爲,一旦他們在文件系統中,您必須使用一些更多(HTML)代碼來獲取&在Apex中顯示它們。無論如何,這裏是我如何做到這一點(在以前的Apex版本中,我相信它是4.0):使用「文件瀏覽」項我暫時將圖像存儲到表中(這是WWW_FLOW_FILES;您寧願使用現在你自己的表格),然後 - 在按下按鈕的過程中 - 我將它們移動到一個目錄中。
過程代碼:
declare
-- l_dest_dir is name of the directory (Oracle object) which points
-- to a filesystem directory
l_dest_dir varchar2(30) := pkg_slike.f_dir_slike_upload_dp(:P0_DP);
begin
for cur_r in (select id, filename
from wwv_flow_files
where upper(filename) like 'TS%.JP%G'
)
loop
-- put a picture into L_DEST_DIR
pkg_slike.p_write_blob_to_file(cur_r.id, l_dest_dir);
delete from wwv_flow_files
where id = cur_r.id;
end loop;
end;
程序代碼:
PROCEDURE p_write_blob_to_file (p_file_id IN NUMBER, p_dir IN VARCHAR2)
IS
/* 19.04.2012. Taken from Eddie Awad's Blog
http://awads.net/wp/2011/09/20/create-an-application-to-upload-files-using-oracle-apex-in-less-than-10-minutes-video/
*/
l_blob BLOB;
l_blob_length INTEGER;
l_out_file UTL_FILE.file_type;
l_buffer RAW (32767);
l_chunk_size BINARY_INTEGER := 32767;
l_blob_position INTEGER := 1;
l_file_name pkg_general.subt_ime_slike;
BEGIN
-- Retrieve the BLOB for reading
SELECT blob_content, filename
INTO l_blob, l_file_name
FROM wwv_flow_files
WHERE id = p_file_id;
-- Retrieve the SIZE of the BLOB
l_blob_length := DBMS_LOB.getlength (l_blob);
-- Open a handle to the location where you are going to write the BLOB
-- to file.
-- NOTE: The 'wb' parameter means "write in byte mode" and is only
-- available in the UTL_FILE package with Oracle 10g or later
l_out_file :=
UTL_FILE.fopen (p_dir,
l_file_name,
'wb' -- important. If ony w then extra carriage return/line brake
,
l_chunk_size);
-- Write the BLOB to file in chunks
WHILE l_blob_position <= l_blob_length
LOOP
IF l_blob_position + l_chunk_size - 1 > l_blob_length
THEN
l_chunk_size := l_blob_length - l_blob_position + 1;
END IF;
DBMS_LOB.read (l_blob,
l_chunk_size,
l_blob_position,
l_buffer);
UTL_FILE.put_raw (l_out_file, l_buffer, TRUE);
l_blob_position := l_blob_position + l_chunk_size;
END LOOP;
-- Close the file handle
UTL_FILE.fclose (l_out_file);
END p_write_blob_to_file;
希望,你將設法將其調整到您的情況。