willdikuloz Posted June 11, 2006 Share Posted June 11, 2006 [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? Quote Link to comment https://forums.phpfreaks.com/topic/11724-upload-chmod-permissions/ Share on other sites More sharing options...
kenrbnsn Posted June 11, 2006 Share Posted June 11, 2006 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 Link to comment https://forums.phpfreaks.com/topic/11724-upload-chmod-permissions/#findComment-44323 Share on other sites More sharing options...
willdikuloz Posted June 11, 2006 Author Share Posted June 11, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/11724-upload-chmod-permissions/#findComment-44336 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.