Removed double setting of upload dir and url
Use === for comparison
Use parse_url instead of explode