Hi how do I get my site to create files? blah.html does not exist and I'm trying to write it. the folder "cache" has permissions set to 777. I am running the script on the same domain as I am trying to create the file on, but it gives the same error as if I tried to write to a different domain. I can only use fopen to read.
It used to work until I got a new server.
PHP Code:
//Try to make a local file. $file = fopen('http://mysite.com/blah.html', 'w'); if($file) { echo "file."; fclose($file); } else { echo "nope."; }
Warning: fopen(http://mysite.com/blah.html) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /chroot/home/mysite/mysite.com/html/fopen.php on line 17
nope.
Warning: fopen(blah.html) [function.fopen]: failed to open stream: Permission denied in /chroot/home/mysite/mysite.com/html/fopen.php on line 6
nope.
Warning: fopen(http://mysite.com/cache/blah.html) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /chroot/home/mysite/mysite.com/html/fopen.php on line 29
nope.
Warning: fopen(/cache/blah.html) [function.fopen]: failed to open stream: No such file or directory in /chroot/home/mysite/mysite.com/html/fopen.php on line 40
nope.
Warning: fopen(http://mysite.com/reconstruct.html) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /chroot/home/mysite/mysite.com/html/fopen.php on line 52
nope.file.
Warning: fopen(/chroot/home/mysite/mysite.com/blah.html) [function.fopen]: failed to open stream: Permission denied in /chroot/home/mysite/mysite.com/html/fopen.php on line 78
nope.
Warning: fopen(http://211.59.25.55/blah.html) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /chroot/home/mysite/mysite.com/html/fopen.php on line 91
nope.
The second one is the way I do it myself and when I pasted your code without change it is the only one which worked (I didn't bother creating the cached directory). That is without 777 permissions set. So if it doesn't work for you it must be something about the server.
Is the location you are trying to write to on the same server as your script? If so you could use fopen without the HTTP wrapper (it is likely it is just URL file handling which is disabled).
Thanks for all the replies. Ok I can get it to work only if the path is "/chroot/home/mysite/mysite.com/html/myfolder" and myfolder permissions is 777. phpinfo() says allow_url_fopen is On.
Any ideas on how to make fopen work with my http:// url?
Surely you would need something sitting on the target machine to receive the data and write the to the filesystem? I could be wrong as I've never tried it, but it doesn't make sense to me. Can you not use FTP instead of HTTP?
Well to me it sounds like this is the beginnings of a site crawler or slurp engine which is possibly why the need for http.
Theirs one / possibly Two method(s) that has not been discussed yet and until we know what the purpose of the function is and its intended purpose, IM not saying owt.
Yes I could understand that if the OP wanted to read via HTTP, but it's the writing via HTTP which is throwing me off. I'm not sure how that would even work without something on the target machine to handle the actual writing to the filesystem.
Bookmarks