You need to make the actual <input type="file"> element associated with the AddPhoto widget visible (you don't show the actual input in your html) and then call attach_file on that. Usually that will mean using execute_script to adjust the CSS of the input element to make it visible.