manalnor Posted March 24, 2011 Share Posted March 24, 2011 Hello dear friends, let say we have text file (file.txt) i wanna php code that makes me able to write some text to this text file (file.txt) then save it as zipped file to be (zipped.zip) 1) I know how to write , will use this <?php $File = "file.txt"; $Handle = fopen($File, 'w'); $Data = "Hello phpfreaks\n"; fwrite($Handle, $Data); $Data = "Hello World\n"; fwrite($Handle, $Data); print "Data Written"; fclose($Handle); ?> now the (file.text) will be saved with the following text Hello phpfreaks Hello World Now the question which i do not know how to save it as zipped file not text file ? OR save it normally as text file (file.txt) then create zipped file of it (zipped.zip) thank you so much for help Quote Link to comment Share on other sites More sharing options...
nethnet Posted March 24, 2011 Share Posted March 24, 2011 Look into the ZipArchive class. I believe this extension is preloaded on most hosts, but if it's not on yours, you should contact your webhost to have it added. A quick phpinfo() will show you if it's there. And of course, if you manage your own server, compile PHP using --enable-zip (on Linux) or enable php_zip.dll in your php.ini (on Windows). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.