Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Highlighted
Contributor
Posts: 22
Registered: ‎01-20-2011
My Device: Bold 9650
My Carrier: Verizon

Storing an image

I have my users fill out a form and take a picture (they do not have access to the internet at the time they fill out the form).  They can fill out multiple entries while they do not have access to the internet.

 

I store the data in SQLite and then when I detect that they have internet access again, I retrieve the data from SQLite and populate a <form> with the stored data and submit the form to my php script. 

 

I need the latter part (retrieving data from SQLite and submitting the data to PHP script) to be as automated as possible, so I will be running this part in the background.

 

What is the right way to deal with the image?  Can I just save the filename (including path) in SQLite?  If I do that, how do I retrieve the image when I am ready to send my data to my PHP script?  Or do I save the image as a BLOB in SQLite?  If so, how do I store the image as a BLOB and how do I retrieve it later on? 

 

Here is the SQLite table I create: 

tx.executeSql("CREATE TABLE IF NOT EXISTS MTAObservations(ID INTEGER PRIMARY KEY ASC, username varchar(50), passwd varchar(50), observed_on DATETIME, problem varchar(50), problem_detail varchar(50), borough varchar(50), subwayline varchar(50), station varchar(50), location varchar(50), imageName varchar (100), comments TEXT, mta_image BLOB)", [], offline.webdb.getMTADataInfo(MTADataInfo), offline.webdb.onError);

 

After the picture is taken, I am able to access the image and show a thumbnail on my page:
   var img = new Image();
   img.src="file://" + filePath;
   document.getElementById("photoDetails").appendChild(img);

 

The form I create to send my data to once internet access is restored:

return "<br><form id='PHPForm"+row.ID+"' name='PHPForm"+row.ID+"' method='post' enctype='multipart/form-data' action='http://38.96.130.170/comnet/testSQL5.php' onSubmit='return checkInternet();'><input name='username' id ='username' type='text' value='"+ row.username +"' ><input name='password' id ='password'type='text' value='"+ row.passwd +"' ><input name='problem' id ='problem' type='text' value='"+ row.problem +"' ><input name='problem_detail' id ='problem_detail' type='text' value='"+ row.problem_detail +"' ><input name='borough' id ='borough' type='text' value='"+ row.borough +"' ><input name='subwayline' id ='subwayline' type='text' value='"+ row.subwayline +"' ><input name='station' id ='station' type='text' value='"+ row.station +"' ><input name='location' id ='location' type='text' value='"+ row.location +"' ><input name='imageName' id ='imageName' type='text' value='"+ row.imageName +"' ><input name='comments' id ='comments' type='text' value='"+ row.comments +"' ><input type='submit' value='Submit'/></form><br><br>";

 

I do have the mta_image field (BLOB datatype) in SQLite, but I do not do anything with it right now.  I am currently only storing the image Name, because I am not sure how to deal with the actual image.

Any suggestions?

Thanks