I have a web form to upload pictures from the users. Then I am creating an iOS app to show the pictures loaded from the users. But the app is not loading the pictures if the file name contains spaces or special characters (like á, é, í, ó, ú, ñ, etc.), most of the users are from Spain...
This is the code I am using:
<?php if ((isset($_POST["enviado"])) && ($_POST["enviado"] == "form1")) {
$randomString = substr(str_shuffle("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 1) . substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 10);
echo $randomString;
$nombre_archivo = $_FILES['userfile']['name'];
move_uploaded_file($_FILES['userfile']['tmp_name'], "logos/".$randomString.$nombre_archivo);
?>
I am using the random function to avoid repeated file names.
How could I change the file name given by the user and that may contain spaces and/or special characters, in a way that can be perfectly loaded in the iOS app?