Jump to content

Upload CHMOD Permissions


willdikuloz

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?
Link to comment
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
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

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.