Mari Masuda wrote:
> 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 ---

What are the permissions on /Applications/apache/htdocs/wp-php/ ?

Apache needs write permissions on that dir in order to create the file
tableToCutAndPaste.txt.

It's probably not a secure idea to give write permissions to that dir,
so maybe create a subdir of tmp and change those permissions (one way):

mkdir /Applications/apache/htdocs/wp-php/tmp
chmod a+w /Applications/apache/htdocs/wp-php/tmp

-- 
Thanks!
-Shawn
http://www.spidean.com

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

Reply via email to