• How do I replace the underscores with spaces in the filename when a user clicks download. The file on the server should not be changed only the user’s copy. the_song_name.mp3 should be ‘The Song name.mp3’

Viewing 4 replies - 1 through 4 (of 4 total)
  • Instead of spaces can you use dashes? That would be more compatible across various platforms than using spaces.

    To do this you’d need to set up a PHP script that gets the file that you want, outputs the required download headers (file type, size, name, etc) and outputs the file to the user then quits. It’s possible, but it’s a bit of owrk for something that doesn’t seem to be an issue for most places. As Dan said, underscoares are normally a better option even though most OS’s these days handle spaces in file names OK.

    Why do you need the file names to have spaces anyway? I’m sure that there’s a good reason behind it. ??

    Thread Starter ZedNerd

    (@zednerd)

    No technical reason. I’m just darn user friendly, and I know underscores or dashes (looks at Dan Poynor) are not something users like to see on filenames. Client devices are fine with spaced filenames. I also think not slapping filenames with underscores looks professional since no cloud storage system does it at least when downloaded.
    I was hoping there’s a hook I could call and use str_replace

    Dashes are just my personal pref mainly for seo reasons:
    https://searchengineland.com/9-seo-quirks-you-should-be-aware-of-146465

    Plus underscores start to look geeky in names while dashes are more familiar/common in text such as in peoples names or place names for example.

    Either looks cleaner than seeing encoded characters in urls though. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Replace underscores with spaces in filename before download’ is closed to new replies.