I wrote a PHP script on my local server which needs to include path for the file where I need to write contents to the file using file_put_contents which was working without any problem on the localhost. I moved the files to the webserver where it has been configured with the path which has spaces in between
for ex:
C:\Program File (xxx)\Apache Software Foundation\Apache2.2\htdocs\writtencode\writefile\
When I try to open the folder writefile to write the contents to temp_1.cfg file in that folder it pops up the error
Warning:
file_put_contents(C:\ProgramFile(xxx)\ApacheSoftwareFoundation\Apache2.2\htdocs\writtencode\writefile\temp_1.cgf)
[function.file-put-contents]: failed to open stream: No such file or
directory in C:\Program File (xxx)\Apache Software
Foundation\Apache2.2\htdocs\writtencode\writefile\index.php
Any idea how to remove or tackle with the problem of spaces in the path when writing contents to the file using file_put_contents?
Have you tried enclosing the path in quote marks?
Also you may need to escape all backslashes so:
file_put_content(C:\ProgramFile(xxx)\ApacheSoftwareFoundation\Apache2.2\htdocs\writtencode\writefile\temp_1.cgf);becomes:
file_put_content('C:\\ProgramFile(xxx)\\ApacheSoftwareFoundation\\Apache2.2\\htdocs\\writtencode\\writefile\\temp_1.cgf');