Jump to content

Archived

This topic is now archived and is closed to further replies.

willdikuloz

Upload CHMOD Permissions

Recommended Posts

[code]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>";
}[/code]


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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[!--quoteo(post=382554:date=Jun 11 2006, 01:10 PM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Jun 11 2006, 01:10 PM) [snapback]382554[/snapback][/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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.