View Full Version : Monitoring of database updating

12-12-2008, 05:57 PM
I've used an iframe to upload image files to the target server and update the database with the files' location.

However, I'm having trouble with displaying the image once the file is successfully uploaded. I'd like for javascript to monitor the updation of the file location in the database and once the file location information is updated in the database to display the image. Anyone know how to do that? Examples would be great. Thanks.

12-13-2008, 02:21 AM
are you looking for a change in img info, or just for the existance of it?

12-15-2008, 05:45 PM
Both the existence and change of the image info. The first time the user edits the image, there is a null stored in the database. Obviously after the user has inserted the image the first time, there will be a change in image info for all subsequent image insertions.

12-15-2008, 10:11 PM
Is the image actually being stored in the database? If so that's a really bad idea.

If not, and the image path/name is the only this stored in the database then I would just add an extra timestamp field called LastUpdated.

When you upload an image just update LastUpdated to reflect the current time.

Your iframe just needs to send an ajax request every so often checking for a timestamp that is not equal to the one from when the page was originally loaded.

12-16-2008, 04:10 PM
dk is right when he says its generally speaking a bad idea to store anything other than text in a database (for a number of reasons).

That said, he emailed me a couple times and I think figured out a way to get what he wants.

Your iframe just needs to send an ajax request every so often checking for a timestamp While this would work, it's much more efficient and exact to create event driven code rather than cyclical checks. He really just needs it to display when and only when it's been uploaded.

12-16-2008, 05:14 PM
No, the image is not being stored in the database, however, the location of the folder/file location is.

I posted my original question sometime ago, and when there were no responses, I re-phrased and re-posted. When there were still no responses, I emailed itsallkizza hoping to pick his mind a bit. After a couple of emails, a simple and effect solution was reached.

I too at first thought of using some repeating code to check if the update was successful/complete. But itsallkizza suggested having the iframe run a js code from the parent document on load - which turned out to be easy and effective.

While on the topic of images, the next task I'm attempting is having a photo album - similar to the ones seen in flickr, facebook, etc. Does anyone have or know of any articles, examples, etc. on how to approach that? General guidlines or suggestions would be appreciated as well. I'd like for the user to be able to upload multiple images at a single time and select orientation. Thanks.