Upload File

liunx

Guest
Hi,<br /><br />I have an account with totalchoicehosting and I'm trying to write a php photo gallery.<br /><br />I want to let the site members to create their galleries by uploading their pictures in a folder named after their account name (<img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />). So the problem is to create a new folder through script and give write permissions for this folder. I tried to use <b>chmod</b> for changing the permissions, but I'm getting this error:<br /><br /><b>Warning</b>: chmod(): Operation not permitted in <b>/home/.../public_html/image.php</b> on line <b>...</b><br /><br /><br /><br /><br />This is the first problem (dynamically setting permission for a new folder).<br /><br />Another problem: I wrote an upload module and I'm getting this error this time:<br /><br />Warning: mkdir(/usr/local/apache/htdocs/images): Permission denied in /home/.../public_html/test.php on line 99<br />Error: Directory does not exist and was unable to be created.<br /><br />even I changed permissions for the folder.<br /><br />Thanks for your responses.<!--content-->
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? <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
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.<!--content-->
Are you usinf cpanels file manager?<br />I have had mixed results with it<br />and now just use an ftp program to change permissions.<!--content-->
<!--QuoteBegin-TCH-Don+May 25 2004, 01:51 PM--><div class='quotetop'>QUOTE(TCH-Don @ May 25 2004, 01:51 PM)</div><div class='quotemain'><!--QuoteEBegin-->Are you usinf cpanels file manager?<br />I have had mixed results with it<br />and now just use an ftp program to change permissions.<!--QuoteEnd--></div><!--QuoteEEnd--><br /> Thank you guys,<br /><br />I figured out the all thing:<br /><br />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.<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> <br /><input type="hidden" name="MAX_FILE_SIZE" value="2048000"> <br />File: <input name="userfile" type="file" /><br /> <br /><input type="submit" value="Upload" /> <br /></form> <br /><br /><?php <br />if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) { <br />       mkdir("images/gallery/dir1", 0777);<br />        copy($_FILES["userfile"]["tmp_name"], "images/gallery/dir1/" . $_FILES["userfile"]["name"]); <br />        echo "<p>File uploaded successfully.</p>"; <br />} <br />?><!--c2--></div><!--ec2--><br /><br />... so first I modified permissions with cpanel for <b>gallery</b> folder and the all the new folders I'm creating them with 0777 parameter.<!--content-->
Good Thumbs Up <br /><br />and oh yes,<br /> <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/kicking.gif" style="vertical-align:middle" emoid=":dance:" border="0" alt="kicking.gif" /> Welcome to the family <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/kicking.gif" style="vertical-align:middle" emoid=":dance:" border="0" alt="kicking.gif" /><!--content-->
 
Back
Top