Einzelnen Beitrag anzeigen
  #1  
Alt 13.06.2016, 13:57:02
Sn0oQRRR Sn0oQRRR ist offline
Anfänger
 
Registriert seit: Jun 2016
Alter: 34
Beiträge: 1
PHP - Dateiupload auf Stratoserver nicht möglich

Hallo zusammen,

ich habe ein frustrierendes Problem bei der Realisierung eines Uploadscripts via PHP. Das Problem ist, dass das Skript auf meinem lokalen XMAMPP-Entwicklungsserver erfolgreich ausgeführt wird. Wenn ich es dagegen auf meinen Strato Webserver kopiere, schlägt der Dateiupload fehl. Ohne jegliche Fehlermeldung, trotz display_errors = On und error_reporting = E_ALL.

Hier ist mein kompletter code, den ich eigentlich von der W3School übernommen habe und in der Datei upload.php gespeichert ist:
PHP-Code:
<?php
$target_dir 
"./uploads";
$target_file $target_dir basename($_FILES["fileToUpload"]["name"]);

$uploadOk 1;
$imageFileType pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    
print_r($_FILES);

    
$check getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if(
$check !== false) {
        echo 
"File is an image - " $check["mime"] . ".";
        
$uploadOk 1;
    } else {
        echo 
"File is not an image.";
        
$uploadOk 0;
    }

    
// Check if file already exists
    
if (file_exists($target_file)) {
        echo 
"Sorry, file already exists.";
        
$uploadOk 0;
    }
    
// Check file size
    
if ($_FILES["fileToUpload"]["size"] > 500000) {
        echo 
"Sorry, your file is too large.";
        
$uploadOk 0;
    }

    
// Check if $uploadOk is set to 0 by an error
    
if ($uploadOk == 0) {
        echo 
"Sorry, your file was not uploaded.";
    
// if everything is ok, try to upload file
    
} else {
        if (
copy($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
            echo 
"The file "basename$_FILES["fileToUpload"]["name"]). " has been uploaded.";
        } else {
            echo 
"Sorry, there was an error uploading your file.";
        }       
    }
}
?>
HTML-Code:
<!DOCTYPE html>
<html>
<body>

<form action="upload.php" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload Image" name="submit">
</form>

</body>
</html>
Das Skript gibt nach jeder Ausführung folgendes aus:

Zitat:
Array ( ) File is not an image.Sorry, file already exists.Sorry, your file was not uploaded.
Wie man sieht ist das $_FILES-Array komplett leer, unabhängig davon was für eine Datei ich hochlade. Ich habe deshalb meine PHP-Konfiguration in der php.ini und per phpinfo() überprüft. PHP ist wie folgt eingestellt:
Code:
file_uploads = On;
memory_limit = 128M;
post_max_size = 128M;
upload_max_filesize = 128M;
upload_tmp_dir = /tmp;
Die Dateien, die ich hochladen wollte, haben die Grenze von 128MB natürlich nicht überschritten.

Das Skript ansich ist nicht das Problem, denn wie erähnt, wird es auf meinem lokalen Server erfolgreich ausgeführt und ist ein Standardskript. Es muss also was mit der Konfiguration meines Strato Webservers nicht stimme. Ich habe mittlerweile aber keine Ahnung mehr, wo ich suchen soll. Hat jemand eine Lösung, eine Idee oder wenigstens einen Tipp?

Danke im Voraus!
Mit Zitat antworten