I am creating a file name like this
var name = $('#top-line').val();
var fname = random+'-'+name+'-something';
Here fname is file name. I don't know what the user might enter in #top-line, how can I escape the characters to be sure about safety.
I tried it with a $top line = somethin "else"
and things got messed up.
From the comment I read I understand that
escape("Need tips? Visit W3Schools!") will produce
Need%20tips%3F%20Visit%20W3Schools%21
My doubt is will the file get saved as
Need%20tips%3F%20Visit%20W3Schools%21
What if someone writes escape(/Need tips? Visit W3Schools!")
EDIT on server I am saving files like
$name = uniqid('somevalue',true);
$file = 'usermemes/' . $name . '.jpeg';
On user computer they have the name that user provides.