fix upload middleware