Jump to content

Superglobal $_FILES is empty on Strato server


Recommended Posts

I have got some frustating problems facing file upload with a php script. The problem is that my script is working on my local xampp server. But when I transfer it to my strato host server it won't work anymore. There is no error output, although I have set display_errors to on and error_reporting to E_ALL.

Here is my complete code which I copied from the w3school file upload tutorial and is stored in the file upload.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"])) {
    $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.";
<!DOCTYPE html>

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


The output of the script after every submission is:

Array ( ) File is not an image.Sorry, file already exists.Sorry, your file was not uploaded.



As you can see the $_FILES array is completly empty.. no matter what type of file I upload.

I checked my php.ini and also phpinfo() for the relevant configuration parameters. This is what I got:

file_uploads = On;
memory_limit = 128M;
post_max_size = 128M;
upload_max_filesize = 128M;
upload_tmp_dir = /tmp;

The files I tried to upload of course did not exceed the limit of 128MB.

The script itself should not cause my problem, since it works on my local XAMPP server and for many other users and servers. There must be something wrong with my strato server configuration, but I can't figure out what the problem is. The php.ini seems wright. Does anybody have an idea, a clue or maybe just a hint?

Thanks in Advance.

Link to comment
Share on other sites

There might be some restriction on the host. If you exceed post_max_size, for example, then both $_POST and $_FILES will be empty, but it sounds like you have values in $_POST. It sounds like something else is going on with the server.

Link to comment
Share on other sites

@davej it means that my server is hosted by strato webhosting (www.strato.de). I read about some problems with this hoster, so I thought I should mention it. Maybe any of you have faced some similar problem?
@justsomeguy the files i tried to upload do not exceed any of the given limits.. It must be something else.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...