Jump to content


Photo

Upload CHMOD Permissions


  • Please log in to reply
2 replies to this topic

#1 willdikuloz

willdikuloz
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 11 June 2006 - 05:06 PM

if (isset($_POST['dat'])) {
 $query = "SELECT post FROM posts ORDER BY post DESC";
 $result = mysql_query($query) or die(mysql_error());
 $pst = 0;
 while ($link = mysql_fetch_array($result, MYSQL_ASSOC)) {
  if ($link['post'] > $pst) {
   $pst = $link['post'];
  }
 }
 $pst++;

 $title = $_POST['title'];
 $dat = $_POST['dat'];
 $reads = 0;
 $type = $_POST['type'];
 $link = $_POST['link'];
  $filetype = $_POST['fileupload'];
 
 $query = "INSERT INTO posts(post,title,type,link,dat) VALUES('$pst','$title','$type','$link','$dat')";
 $result = mysql_query($query) or die(mysql_error());
 $target = "$filetype/"; 
 $target = $target . basename( $_FILES['uploaded']['name']); 
 $ok=1; 
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} 
else {
echo "Sorry, there was a problem uploading your file.";
}
echo "<h3><center><a href=\"addpost.php\">CLICK HERE</a></center></h3>";
} else { 
 echo "<form action=\"addpost.php\" enctype=\"multipart/form-data\" method=\"POST\">";
 echo "<br>";
 echo "Title: <input name=\"title\"><br>";
 echo "Link: <input name=\"link\"><br>";
  echo "Category:
<select name=\"type\">
<option>Select A Category!</option>
<option value=\"image\">Image</option>
<option value=\"movie\">Movie</option>
<option value=\"flash\">Flash</option>
<option value=\"pron\">Porn</option>
<option value=\"link\">Links</option>
</select><br>";
 echo "File: <input name=\"uploaded\" type=\"file\"><br>";
   echo "Type :
<select name=\"fileupload\">
<option>Select A Type!</option>
<option value=\"images\">Image</option>
<option value=\"movies\">Movie</option>
<option value=\"flash\">Flash</option>
</select><br>";
 echo "<input type=\"hidden\" value=\"" . strtotime(now) . "\" name=\"dat\">";
 echo "<input name=\"submit\" type=\"submit\" value=\"Add new post!\">";
 echo "</form>";
}


here is my code, I have an upload script but the problem is whenever I upload something, it has the wrong permissions, especially with pictures (which can't be viewed due to bad permisisons). Is there anyway I can upload the file with 777 permission?

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 11 June 2006 - 05:10 PM

The permission problem is not with the uploaded file, but with the directory you're putting the pictures in. The permissions on the directory have to be set such that the user that the webserver is using (usually nobody) can write to the directory.

Ken

#3 willdikuloz

willdikuloz
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 11 June 2006 - 05:55 PM

[!--quoteo(post=382554:date=Jun 11 2006, 01:10 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Jun 11 2006, 01:10 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
The permission problem is not with the uploaded file, but with the directory you're putting the pictures in. The permissions on the directory have to be set such that the user that the webserver is using (usually nobody) can write to the directory.

Ken
[/quote]
I've heard about that but have no idea how I can do that.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users