I also had this problem with Prestashop 1.5.6.1 on local server. I spent several days to find the reason of the problem. The reason of error was simple. By default new image legend is already entered in the field and is the same as products's name. If it exceed 128 symbols, you'll get error "undefined" while uploading an image!
DON'T FORGET CHECK LEGEND'S LENGTH ON ALL LANGUAGES! Developers should definetly make correct error report for this error. Not unclear "undefined" disappearing within a several seconds, but something like "Length of image's legend is too long"! I remember that I meet that problem several months ago and also cannot resolve it. Each time I couldn't understood, what mean the 'undefined" error. And solution and reason was the same - too long legend name. But now I couldn't remember this once again due stupid formulation - "undefined" instead clear "Length of image's legend is too long". There is other bad things of trying upload images with too long image legend: 1. First of all when finally by case you success with uploading (for example, by shortening legend's length) the image's position in image's list will be wrong. For example, I tried upload the first image of a product seven times. Finally, when I shorten legend to 128 symbols I can successfully upload the image. It is so far the only image of product, but is position in lis is 8. 2. I checked the ps_image table to manually correct this problem. I have found there seven leftovers of my unsuccessful attempts to upload images - seven unneeded id_image of non-existing images. I removed them all and manually changed position in the table. Please correct such behaviour of Prestashop when uploading an image is unsuccessful FOR ANY REASON. Prestashop should write results in the table only after successful uploading.