Hey All!
i am currently attempting to validate the file name that can be uploaded as a user's image on my registration page.
I currently have it working in that the file uploads to the server and the image source is placed into the database which then displays the image when called.
However if there is a space in the file name, i.e. my file.jpg then my file is not being displayed. I have tried using JavaScript validation to block whitespace although whitespace is needed for the full file name, i.e ../documents and settings/...
The code i have looks like this:
$target_path = "photos/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "image uploaded";
} else{
echo "image upload failed";
}
Is there a line of code i could use to strip the whitespace from what is being sent to both the server and my database field? Or any other way which anybody can think of?
Thanks in advance
GavW