Image manager in PHP and Javascript