Go4Expert (http://www.go4expert.com/)
-   JSP (http://www.go4expert.com/forums/jsp/)
-   -   Upload file in JSP with Oracle Database 10gR2 (http://www.go4expert.com/forums/upload-file-jsp-oracle-database-10gr2-t25383/)

blueangel 31Mar2011 08:55

Upload file in JSP with Oracle Database 10gR2
How to upload file with oracle database 10gR2??
i can't find how to upload..
i've tried to create a procedure in oracle and execute in netbeans but the file save in directory and then from directory save to database.
it means the file save in 2 location, in directory and database..
does anybody know how to save file direct from the JSP file into database without save in directory?

this is the procedure..


create or replace PROCEDURE load_file (
p_id number,
p_photo_name in varchar2) IS

src_file BFILE;
dst_file BLOB;

src_file := bfilename('DIR_TEMP', p_photo_name);

-- insert a NULL record to lock
INSERT INTO temp_photo
(id, photo_name, photo)
(p_id , p_photo_name ,EMPTY_BLOB())
RETURNING photo INTO dst_file;

-- lock record
SELECT photo
INTO dst_file
FROM temp_photo
WHERE id = p_id
AND photo_name = p_photo_name

-- open the file
dbms_lob.fileopen(src_file, dbms_lob.file_readonly);

-- determine length
lgh_file := dbms_lob.getlength(src_file);

-- read the file
dbms_lob.loadfromfile(dst_file, src_file, lgh_file);

-- update the blob field
UPDATE temp_photo
SET photo = dst_file
WHERE id = p_id
AND photo_name = p_photo_name;

-- close file
END load_file;

All times are GMT +5.5. The time now is 09:13.