Jump to content

Recommended Posts

Posted

Hi,

 

I have an account with totalchoicehosting and I'm trying to write a php photo gallery.

 

I want to let the site members to create their galleries by uploading their pictures in a folder named after their account name (:blink:). So the problem is to create a new folder through script and give write permissions for this folder. I tried to use chmod for changing the permissions, but I'm getting this error:

 

<b>Warning</b>: chmod(): Operation not permitted in <b>/home/.../public_html/image.php</b> on line <b>...</b><br />

<br />

 

This is the first problem (dynamically setting permission for a new folder).

 

Another problem: I wrote an upload module and I'm getting this error this time:

 

Warning: mkdir(/usr/local/apache/htdocs/images): Permission denied in /home/.../public_html/test.php on line 99

Error: Directory does not exist and was unable to be created.

 

even I changed permissions for the folder.

 

Thanks for your responses.

Posted

Why not try one of the already made galleries like ht*p://coppermine.sourceforge.net/ or ht*p://gallery.menalto.com/modules.php?op=modload&name=News&file=index to name a few? :blink:

Posted

Even if I'm gonna use a free php module I will not get it working; because the problem seems to be the permissions on the uploading folder.

Posted
Are you usinf cpanels file manager?

I have had mixed results with it

and now just use an ftp program to change permissions.

Thank you guys,

 

I figured out the all thing:

 

I changed permissions through cpanel for my "parent" folder and when I am uploadingthe picture, I'm building in the same time the new folder with writing permissions and then saving the picture right there. It's working.

 

><form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> 
<input type="hidden" name="MAX_FILE_SIZE" value="2048000"> 
File: <input name="userfile" type="file" /><br /> 
<input type="submit" value="Upload" /> 
</form> 

<?php 
if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) { 
      mkdir("images/gallery/dir1", 0777);
       copy($_FILES["userfile"]["tmp_name"], "images/gallery/dir1/" . $_FILES["userfile"]["name"]); 
       echo "<p>File uploaded successfully.</p>"; 
} 
?>

 

... so first I modified permissions with cpanel for gallery folder and the all the new folders I'm creating them with 0777 parameter.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...