Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Sep 2008
    Posts
    205
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Monitoring of database updating

    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.

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    are you looking for a change in img info, or just for the existance of it?

  • #3
    Regular Coder
    Join Date
    Sep 2008
    Posts
    205
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder
    Join Date
    Aug 2002
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    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.
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • #6
    Regular Coder
    Join Date
    Sep 2008
    Posts
    205
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •