For Version 4.0.01, the following file is slightly different on code starting from "function handle_file_upload ..."
I do not want to insert the coding here but you can check my ticket #OXO-741609

/libs/upload/upload.php

Hope to hear your answer soon as I want to do the patch now