0

I have created a JQuery image upload plugin that, when you choose a file, it uploads it, and also shows a preview of the image. The plugin also accepts an optional object, that contains a key value collection to be posted along with the image.

I'd like to return another object of results (return some values and create an object), and then extend the existing key value collection with this new object, so that if the user uploads another image with same uploader, it will be replaced with the old one -- instead of creating another record.

For example, this object is passed to uploader:

{imageid : 0, userid: 15}

The image uploads and the imageid of the uploaded image returns (for example 50).

Nnow, I want to build an object like {imageid: 50}, and if the user uploads another image with the same uploader, this time it posts these values:

{imageid : 50, userid: 15} 

The reason that I don't want to check and update values of the existing object is that the return values may have some more entries, some that doesn't even exist in the curren object. Like in this case:

{imageid:50, filename:'abc.gif'}
Rubens
  • 14,478
  • 11
  • 63
  • 92
Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171

0 Answers0