Sadly, you need to debug it, and I can't do it form here.
I would start by doing an
echo "The required file is [".$requiredfile."]";
On the line after where you assign the value to $requiredfile.
This should echo out what PHP thinks the file is called.
If this line doesn't appear at all when you run the program, it's because the "if(isset" failed. You need to doublecheck what's going on there. Maybe echo the value of $_POST["password"];
If the line appears but the value between the square brackets doesn't match the full path to the image file, you need to change some of the variables in the script to get it right.
If the line appears and the value between the square brackets is right but nothing else happens, that file may not be readable - check the permissions.
If the line appears and is correct, and you get an error saying "unable to send headers", then all would appear to be fine, it's just that the echo you just put in is breaking the "headers" commands.