I am trying to create and then edit a file on and mcpe server from a PocketMine plugin. Unfortunately, my code does not work. Here it is: PHP: $fp = fopen (dirname(__FILE__) . "/foo.zip", 'w+');$sender->sendMessage($fp); The file is not created and no message gets sent. How should I create and edit files with PocketMine, or how should I fix my code?
when you use fopen it returns an resource handler not text therefore it should fail your console log should say something to fix it i would do Code: $text = fread($handler) fclose($handler) $sender->send($text) hopefully it works no clue not tested
fopen returns a resource, not a string. You would need to use stream_get_contents to get the contents of that resource and send that to the player (if it's text).
I hope you aren't trying to send the whole binary buffer in the ZIP to your players directly. Do you just want to edit a standard file, or edit a file in a zip archive? These are very different. Also, you won't want to use "w+". It will overwrite a file, with the support of random file access, which I don't understand why you need. If you just want to make a zip archive, use the ZipArchive class and you don't need to handle any streams directly at all.
I am not trying to edit a file at all. I simply needed to make one then write to it. I found the solution.