how to import images through the excel file.

how to import images through the excel file.

Hi ,

I have a one requirement.

I have to import employees data with images.

Ex: I have 100 records.
1) Emp Name
2) Emp ID
3) Emp Mobile
4) Image.

For iamge I wanted to privide the path in Excel file like ( C:\Users\Downloads\image.jpg).

can any one tell me how to implement import iamges with data.

This is definitely doable, but I suggest you change your approach slightly.  

You will have some uneccessary difficulty if you specify the source path as a physical path in the excel file, because application (web server) will probably not have the appropriate access permissions to the physical folder.

I believe an easier way would be as follows:

NOTE: I assume our employee table contains a binary column to hold the image data.


1. Create the excel file with the Emp Name, Emp ID and Emp Mobile columns only.
2. Name the image associated with each employee as <Emp ID>.jpg
3. Combine all the image files into a single zip file.

Now for the processing part:

1. Create an import process to load and process the employee data from the excel file.
2. Create a separate action to upload and process the zip file with the images.  

You can use the functionality of the built-in Zip extension to extract the files from the zip, and then store each file in the appropriate employee record. You can match the files to the correct employee record using the employee id.

Hope this helps
Izak can you give more details about the import of the zip file and how to store each file in the approriate record.

First, in the employee table, make sure you have a column (e.g. Photo) of type binary data.

Second, make sure you have references the "Zip" extension in your espace.  It is a standard platform provided extension.  You are going to specifically need the "LoadZip" and "GetFIles" actions of the extension. 

Now upload the zip file with a standard upload widget on the form.  

In the form action after the form is submitted, call the "LoadZip" action and pass it the binary content uploaded with the upload widget.  The action will return a "ZipHandle" output value.  

Now call the "GetFiles" action and pass it the ziphandle value.  The "GetFIles" action will return a record list of the files contained in the zip.  Each file item will have a "Content" attribute which will contain the binary content of the file (in your case the image).

Now cycle over the record list and for each iteration, use the file name value (which in your case is the EmpID.jpg) to find the correct employee record.  You can parse the employee id from the file name with a "String_Split()" function (available in the Text extension)  and the use a standard query to get the employee record.  

Once you have the employee record, set the value of the Photo attribute = the "Content" value of the file record and write the updated employee record to the database. 

That should do it.

PS.  I wrote this response in relation to the original post, so if your scenario is slightly different, you will need to adapt.