Zymic Forums

Webmaster resources

Zymic IRC Server

Chat in real time at irc.zymic.com - Learn More

Welcome

Welcome to the Zymic webmaster forums. Our forums are here to provide people the free ability to discuss a range of websites related topics such as design, development coding and marketing.

In order to post you will need to register for a zymic account or if you already have one simply login by using the form on the left.

left Zymic Webmaster ForumsZymic Free Web HostingZymic Free Web Hosting - General Discussion & Help right
left right
Najm-ul-Abideen
post Sep 25 2007, 02:54 AM
Post #1


Newbie
*

Group: Members
Posts: 5
Joined: 21-September 07
Member No.: 367



Thanks,

Basically I was doing this on:

http://gifs.zxq.net

As you can see on the site I am keeping images, and I am having cautions to avoid porn or other abuse images uploaded by the users. Therefore I made a script to list down all and delete. But when I submit the page it gives me the error of "permission denied in xyz page", therefore I changed the chmod("filename",0777) then execute but now it gave me the error permission not permitted in this situation what I suppose to do.

And I also chown("filename","user") but it is giving error that unable to find uid "user" 1st I have used my username and then the ftp username but on both I got this

please help me as soon as possible as I have to complete this, its complete just this tasks remaining as during upload I am in same situation which is basic for my site.

Thanks,

Najm.
Go to the top of the page 
 
  + Quote Post
 
Start new topic
Replies
Ed
post Sep 25 2007, 02:21 PM
Post #2


Outrageously Uber Ninja
*******

Group: Administrators
Posts: 2,831
Joined: 11-March 07
From: UK
Member No.: 9



There should be no reason to chown the file, the webserver runs via mod_php and file permissions assume that of the webserver (user 'vhostswww' and group 'vhosts'). Your username is completely virtual and the user does not exist in the *nix respect.

By chmoding it to '770' the group ftp users and web server is in should have access to writing to that file. I wrote a little test script:

The ftp session (ncftp is my ftp client):
CODE
ncftp / > mkdir uploads
ncftp / > chmod 770 uploads

# drwxrwx---    2 3448     vhosts       4096 Sep 25 15:36 uploads


The creation:
CODE
<?php
touch('./uploads/test.txt');
?>


The file write:
CODE
<?php
$fp = fopen('./uploads/test.txt', 'w');

if($fp !== false)
{
   fwrite($fp, 'Some content');
   fclose($fp);

   echo 'Content written.';
}
else
{
   echo 'Error. Can not open file pointer.';
}
?>


This went without a hitch, the contents of that file being 'Some content'.

Directory listing was also fine:
CODE
$dir = opendir('./uploads');

while($file = readdir($dir))
{
   if($file == '.' || $file != '..')
      continue;

   echo $file, "\n";
}


So there is no need to chown or chmod inside of your script, providing the directory / file has sufficient permissions it will write to it, and you'll be able to list the contents.

Go to the top of the page 
 
  + Quote Post

Posts in this topic

 Closed Topic Start new topic
left right
0 Members:
left right
 


Lo-Fi Version Time is now: 24th May 2013 - 09:45 AM