I am looking for a piece of code that will ignore the spaces in file paths and file names.
I have a variable ($longName) that holds a path (C:/Program Files/file 2.doc)
When I want to create a link for the path, it falls over at the space. Any ideas would be great.
Code to ignore/remove spaces in filenames/paths
Moderator: General Moderators
Just use:
This should output: "C:/Program%20Files/file%202.doc" which should work in a link
Code: Select all
<?php
$link = "C:/Program Files/file 2.doc";
$newlink = str_replace(" ", "%20", $link);
?>