jakestyler: Upload von .htaccess-Dateien verbieten

Beitrag lesen

Da mir aber sowohl die Frage, als auch die Antwort trivial erscheint, beschreibe bitte etwas > genauer, wo du das Problem siehst.

Im Fileupload soll man alles hochladen können. Per .htaccess-Datei verhindere ich das ausführen von Skripten wie PHP. Wird die .htaccess überschrieben, können ja verschiedene einstellungen vorgenommen werden. Das möchte ich verbinden.

Kannst du mir vielleicht anhand meines Scripts zeigen, wie das funktioniert?

<?php  
$newfile = $_FILES['userfile']['name'];  
if(isset($_POST['send']) && $_POST['send'] == "1"){  
	  
$text_zufall[1] = "uploads/14c1bd94/";  
$text_zufall[2] = "uploads/14c1bd95/";  
$text_zufall[3] = "uploads/14c1bd96/";  
$text_zufall[4] = "uploads/14c1bd97/";  
$text_zufall[5] = "uploads/14c1bd98/";  
$text_zufall[6] = "uploads/14c1bd99/";  
$text_zufall[7] = "uploads/14c1bd100/";  
$text_zufall[8] = "uploads/14c1bd101/";  
$text_zufall[9] = "uploads/14c1bd102/";  
$text_zufall[10] = "uploads/14c1bd103/";  
$text_zufall[11] = "uploads/14c1bd104/";  
$text_zufall[12] = "uploads/14c1bd105/";  
$text_zufall[13] = "uploads/14c1bd106/";  
$text_zufall[14] = "uploads/14c1bd107/";  
$text_zufall[15] = "uploads/14c1bd108/";  
$text_zufall[16] = "uploads/14c1bd109/";  
  
$zufall_key = rand(1,16);  
$uploaddir = $text_zufall[$zufall_key];  
  
  
	if(move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir . $_FILES['userfile']['name'])){  
		$long_url = "http://meinedomain.com/$text_zufall[$zufall_key]$newfile";  
		$bitly = bit_ly_short_url($long_url);  
		echo "<div class='animated flipInX alert alert-success'>  
  <button type='button' class='close' data-dismiss='alert'>&times;</button>  
  <strong>Success!</strong> Your file is now available for 24h: <a href='$bitly'>$bitly</a><br><a href='mailto:yourfriend@example.com?subject=My%20File%20for%20you!&body=Hey!%20:)%0D%0A%0D%0AI uploaded a file:%20$bitly%20%0D%0A%0D%0AHave fun with it!%20'>Send via E-Mail</a> / <a href='https://twitter.com/intent/tweet?original_referer=https%3A%2F%2Ftwitter.com%2Fabout%2Fresources%2Fbuttons&text=I%20uploaded%20a%20file!&tw_p=tweetbutton&url=$bitly'>Share on Twitter</a></div><p>&nbsp;<br>";  
  
        }  
    else{  
        echo "<div class='animated flipInX alert alert-error'>  
  <button type='button' class='close' data-dismiss='alert'>&times;</button>  
  <strong>Oh uh!</strong> Sorry, no file for you.</a>  
</div><p>&nbsp;<br>";  
        }  
    }  
?>