Hi,

I need to open a file using fopen() and the file name contains spaces in it.

I don't control the naming for these files, I need to open the files that are uploaded by someone else. So I can't simply remove the spaces from the filenames.

It is running on a Linux server.

When I check if file exists using file_exists, it works fine. But fopen never finds the file.

Thanks for your help!

Regards,
Veronica

    When you access the file, try:

    fopen(str_replace(" ", "\x20", $filename), "r");

      Thank you thank you thank you!!!!
      It worked 🙂

      I had tried replacing with %20, escaping with \, placing filename inside single quotes and nothing worked. This did the trick 🙂

        Glad it worked.

        Please mark this thread resolved using the thread tools.

          Write a Reply...