How to make a dynamic jigsaw puzzle


I am currently working on Dynamic jigsaw puzzle, I have already finished the puzzle which works fine with single image which is in the library, but My requirement is like any user can upload his/her image to the puzzle and made it as jigsaw, I mean dynamically uploading an image to current file.

How can I dynamically change the current image with that of newly uploaded image please help me in this regard ASAP

Thank you