« Return to Thread: cannot figure out permissions for fopen/fwrite

cannot figure out permissions for fopen/fwrite

by Mari Masuda-2 :: Rate this Message:

Reply to Author | View in Thread

Hello,

This is probably a dumb newbie question.  I am running PHP 5.2.5 and  
Apache 2.2.8 on my Mac Book Pro OS X 10.4.11.  I compiled PHP and  
Apache from source a while ago (as opposed to using the built-in web  
server that is included w/ Mac OS X).  I have written the below PHP  
whose purpose is to read an existing comma separated (CSV) file and  
save the data into a text file that I can later copy and paste from  
into my website content management system.  The problem is that on my  
Mac, I cannot seem to figure out what permissions I need to set in  
order to make the input CSV and the initially non-existant output  
text file readable and writable by Apache/PHP.  I have Googled and  
come across many pages about different ways to set permissions and  
different permissions to set but none of the ways suggested that I  
tried seemed to work for me.  As a temporary solution, I uploaded my  
PHP file to a Windows 2003 server running Apache and PHP and it  
worked flawlessly (and makes me suspicious that there is some huge  
security hole with the Windows box since it was able to execute with  
no permissions modifications).  Any tips would be greatly  
appreciated.  Thanks!

Mari

--- start my code ---
<?php

        $in = fopen("/Applications/apache/htdocs/wp-php/wp.csv", "r");
        $out = fopen("/Applications/apache/htdocs/wp-php/
tableToCutAndPaste.txt", "w");
        $counter = 0;


        fwrite($out, "<table>\n");

        while(($data = fgetcsv($in)) !== FALSE) {
                $paperNumber = $data[0];
                $authors = $data[1];
                $title = $data[2];
                $filename = $paperNumber . ".pdf";

                if(($counter % 2) == 0) {
                        fwrite($out, "<tr>\n");
                } else {
                        fwrite($out, "<tr style=\"background: #cccccc;\">\n");
                }

                fwrite($out, "<td><a href=\"http://www.example.com/workingpapers/ 
getWorkingPaper.php?filename=$filename\">$paperNumber</a></td>\n");
                fwrite($out, "<td>$authors</td>\n");
                fwrite($out, "<td>$title</td>\n");
                fwrite($out, "</tr>\n");

                $counter++;
        }

        fwrite($out, "</table>\n");


        fclose($in);
        fclose($out);

?>
--- end my code ---

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

 « Return to Thread: cannot figure out permissions for fopen/fwrite