• Resolved tvinson

    (@tvinson)


    I’m having an issues with attachment url’s breaking when files are uploaded with white space in the file name. I’ve tried editing the mdocs_rename_file function to include white space but either I’m not editing the correct code or my syntax is off as nothing I do seems to have any effect on the file renaming that happens upon uploading the document. Is there a simple code snippet I can use or alteration I can make to achieve this?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author bhaldie

    (@bhaldie)

    File handling is handled server side, meaning if you have configured your server to remove white space from file name then that is what the outcome will be.

    On my test server if I upload a file called “example file.txt” the uploaded file will be untouched and will look like “example file.txt”

    Thread Starter tvinson

    (@tvinson)

    So you’re saying I can’t use the code you have in there now that replaces commas with dashes to also replace blank spaces with dashes as well?

    Note: The WordPress Media Library removes the spaces just fine but uploading through mdocs does not.

    • This reply was modified 8 years, 5 months ago by tvinson.
    Plugin Author bhaldie

    (@bhaldie)

    that function is used to rename a file if it already exists on the server already appending it with a 1

    so no that function can’t help you.

    The php function that is used to upload a file is “move_uploaded_file”

    http://php.net/manual/en/function.move-uploaded-file.php

    There is no other parsing other than the removal of comma’s

    Thread Starter tvinson

    (@tvinson)

    My syntax was off, like I suspected.
    The code below is all I was requesting… it works as intended and does exactly what I needed it to do.

    $filename_no_comma = str_replace([' ',','],'-',$file['name']);

    Plugin Author bhaldie

    (@bhaldie)

    Great glad you found a solution!!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Remove white spaces from file names’ is closed to new replies.