ive right guys had a problem with file permissions with the following download form. the text file is transferred to upload / dir by global users.
mysite$ ls -l drwxrwxrwx 2 user user 4096 2010-09-24 13:07 upload
but since I am not registered as root, the new file uploaded to the domain is saved in upload / dir with limited permissions and cannot be changed. eg.
upload$ ls -l -rw-r--r-- 1 www-data www-data 3067 2010-09-24 13:07 Readme.txt
this problem is obviously the same for all files added to the download folder by global users. after downloading the file, I need a way to change the rights to the file without introducing the root password in the php script running in the domain. please, help!
Is there a way to associate the same rights with files as the contained folder when adding new files?
send form:
<html> <body> <form action="upload_file.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" id="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html>
upload_file.php:
<?php if ($_FILES["file"]["type"] == "text/plain") { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("/home/user/mysite/upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "/home/user/mysite/upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>
Jb87 source share