How would I validate a string to check that it is safe for a URL. No spaces or special characters in the filename which may break the URL in gmail.
E.g: data/Logo - free.png
would be invalid
I would only like: "a-z", "0-9", ".", "-", "_"
There are hundreds of questions for validating URLs on here but they all seem to check if it contains "http" which I dont need.
UPDATE with working code (from @minitech):
// validate filename
if (preg_match('/[^\w.-]/', basename($logo))){
$error = true
}