php - fopen creates the file but fwrite doesn't write any data and returns 0 -


Below is the part of the OpenX server code (SmartP plugin) when called a phopan, the file is created successfully, but the fileta file Does not write any data and returns 0 (and not incorrectly).

The folder has the following permissions: drwxrwxrwx none

has been created with the following permissions: -R-R-R-A - None

Here's the code.

  function smarty_core_write_file ($ params, & $ smarty) {$ _dirname = Dynamic ($ params ['filename']); If ($ params ['create_dirs']) {$ _params = array ('dir' = & gt; $ _dirname); need_once (SMARTY_CORE_DIR. 'core.create_dir_structure.php'); smarty_core_create_dir_structure ($ $ params, $ smarty); } // to write the tmp file, then rename it to avoid the locking of the file $ _tmp_file = tempnam ($ _ dirname, 'wrt'); If (($ fd = fopen ($ _tmp_file, 'wb'))) {$ _tmp_file = $ _dirname} DIRECTORY_SEPARATOR uniqid ('wrt'); If (($ fd = fopen ($ _tmp_file, 'wb'))) $ $ smarty-> Trigger_ar ("temporary file '$ _tmp_file' 'write problem); description is false;}} Fwrite ($ fd, $ params [' content ']); fclose ($ fd); if (DIRECTORY_SEPARATOR ==' \\ '| | | Rename ($ _tmp_file, $ params ['filename'])) {// platform and file system that can not overwrite with renaming () // delete the file before renaming it - because The windows are always / / it suffers, this is a low-circuit to avoid changing the initial name (try) unlink ($ params ['filename']); Rename ($ _tmp_file, $ params ['filename']); } C Hmod ($ params ['filename'], $ smarty- & gt; _file_ermerm); return true;}   

Below is the code I used to test this function: < / P>

  $ params = array ('filename' => '/ usr / apache / www / templates_compiled / %% 72 ^ 729 ^ 729250E1 %% main.html.php', ' Content '= & gt;' teststring ',' create_dirs' = & gt; TRUE; smarty_core_write_file ($ params, NULL);    

The problem was that the server was full. So after freeing some space, the code worked fine.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -