Home » Developer & Programmer » Forms » read image from a directory (form 6 i)
read image from a directory [message #579876] Sat, 16 March 2013 07:12 Go to next message
alijeyan
Messages: 184
Registered: January 2007
Location: IRAN
Senior Member
Hi
I have 100 image file in C:\My_PIC
i want read these image files and put in a table .

My table have 2 column : Id_pic varchar2(20) ,
PIC BLOB

I want read all files in C:\MY_PIC and Insert in My table with a BUTTON in My form

ID_PIC = file name
PIC = image

please HELP ME
Re: read image from a directory [message #579879 is a reply to message #579876] Sat, 16 March 2013 07:23 Go to previous message
mughals_king
Messages: 392
Registered: January 2012
Location: pakistan
Senior Member
Simple dear



----------you can read images one by one and insert into the database-----------------

:CONTROL.file_path := get_file_name('C:\MY_PIC', NULL, 
    'JPEG Image (*.JPG,*.JPEG,*.JPE,*.JFIF)|*.JPG|Bitmap Image (*.bmp)|*.bmp|GIF Image (*.GIF)|*.GIF|TIFF Files (*.tif)|*.tif|All Files (*.*)|*.*|', NULL);

DECLARE
	image_path VARCHAR2(200);
	image_extension VARCHAR2(3);
BEGIN
	image_path := :CONTROL.file_path;
	image_extension := SUBSTR(:CONTROL.file_path, -3);
	READ_IMAGE_FILE(:CONTROL.file_path, image_extension, 'MAIN.IMG');

END;
----------------------------------------------------------------------------


OR if you wanted saved complete directory in same time then follow this

CREATE OR REPLACE DIRECTORY images AS 'C:\MY_PIC';

Next we create a table to hold the BLOB.

CREATE TABLE tab1 (
id NUMBER,
blob_data BLOB
);

We import the file into a BLOB datatype and insert it into the table.

DECLARE
   l_bfile BFILE;
   l_blob BLOB;
BEGIN
   INSERT INTO tab1 (id, clob_data)
          VALUES (1, empty_blob())
   RETURN clob_data INTO l_blob;

          l_bfile := BFILENAME('IMAGES', 'mughals.gif');
          DBMS_LOB.fileopen(l_bfile, Dbms_Lob.File_Readonly);
          DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
          DBMS_LOB.fileclose(l_bfile);

COMMIT;
END;


Mughal
Smile

[Updated on: Sat, 16 March 2013 07:33]

Report message to a moderator

Previous Topic: Microsoft TreeView Control 6.0
Next Topic: Download ( Call a form from a Report)
Goto Forum:
  


Current Time: Mon Jul 01 10:44:41 CDT 2024