Panel > After File Upload: "The file has not been found"

Hello there lovely kirbys! :smile:

I am observing a strange error message when trying to upload an mp3 file via the panel.
The loading bar progresses up to 100% and then it tells me within the upload modal: “the file has not been found”.

I honestly have no clue where to even start looking with this problem.

We are running
PHP Version 5.4.40-1~dotdeb+squeeze.1
and Apache 2.0
if that is of any importance…

I tried different files and other files (even smaller mp3s) work… therefore I suspect its the file size, because its about 12MB big but I couldn’t find anything that hints to a maximum upload file size.

When searching for the error message on google I find a link to the old forum, but the post has been deleted.

Any help would be much appreciated :smile:
Thank you!

There is an issue on Github re. wrong error message in the panel https://github.com/getkirby/panel/issues/479 when the file size is too big.

As regards the file size itself, is that on a remote server where maybe the file size is restricted by php? You might have to adjust your upload_max_filesize and post_max_size in your php.ini

1 Like

Hint: Look in the PHP config (like php.ini) of your webserver for upload_max_filesize:

Maximum allowed size for uploaded files.
http://php.net/upload-max-filesize

1 Like

ah I see, alright, I will notify the server admin and see if that solves it :smile:

thanks to the both of you! :smile:

So my server admin changed the upload_max_filesize appropriately, but the error persists.
I then reckon it’s more of a problem of the server not being setup quite right than a kirby-related problem.

Therefore I will try to seek help elsewhere :smile:

If anyone else encounters this error, I started to look for php upload issues and there are plenty of things to look for.

Thanks again !

Hi there again!

So we have not been able to overcome this problem yet. We assume it may stem from the user-/group-permission setup and how that works with the panel. But we are not sure.

What would be a basic approach to setting up the server for Kirby?

From what I hear from my server admin, there is the www-data user which is the regular user but also the one that would be editing content via the panel. If that user is not allowed to do this, the panel becomes inaccessible (“check folder permissions” etc.). But, if they do get the permission, we see different security issues there, since Kirby doesn’t use a Database and the user needs to have permission to edit content inside the www folder structure. Or are we doing something inherently wrong?
Another user would be the FTP user which I apparently used to upload Kirby cms.

The server admin now added the www-data user to a group which the ftp-user is in as well and now I can create and delete pages and edit content, but I cannot upload any files. It still says “The file has not been found”.
The permissions are currently set to 775. I found the Wordpress article for setting permissions but it hasnt been helpful in the sense, that if I set permissions to 755 for folders and 644 for files, I can’t edit content anymore via the panel and the problem may lie in the general user/group setup which I personally wouldn’t know how to set up normally.

The phpini can be found here for server specs: http://www.josuagemeinde.de/phpinfo.php

I am really grateful for any help on this, I have had a lot of trouble wrapping my head around this the past month! Especially since I am anything but a server admin, I usually don’t mess with that kinda stuff :smiley:

Setting permissions to 775 can be (depending on the server and if it is used by other people and sites as well) quite dangerous, as everyone on the server will be able to read every file.

I’d recommend setting the file and directory owner to the www-data user for the content directory and the cache and thumbs directories (every directory that gets modified by Kirby). After that you won’t be able to modify these files/directories via FTP, but as you are using the Panel you probably won’t have to do that anyway.

The file upload issue can have very many reasons (as you wrote previously). Does a very simple file upload demo script work (simply use an example from somewhere, for example from the PHP docs)? If it doesn’t, you might be able to track down the issue by printing out the file data array $_FILES.

I see, I informed my server admin.

Regarding the php file upload, after uploading the file with a simple php upload script, like you said, the upload.php script page opens and shows nothing, although it should print “Success” when it is finished :smile:
If I tell it to print the array $_FILES it of course does the same (no)thing.

Not sure what is happening here.

Did you check your settings for post_max_size as well? Even if upload_max_filesize is set correct, the post_max_size value might block the upload.

We did and put them both at 40M since about 36M will be the max file size that we expect to be uploaded via the panel.

Are you getting HTTP 500 after uploading a file?

Are referring to the PHP Upload Test Script or the Panel Upload?
In both cases I don’t get HTTP 500.

With the test script the page is blank after upload and the body empty. Not sure if I’m doing something wrong with the upload script, but when I press upload, it opens the upload.php (which is the script) and the page is empty. Is it supposed to do that at all?

You can try it at josuagemeinde.de/phpupload.php

Could you please point me to the source of the phpupload.php script so I can take a look at the code?

I don’t know how to point you there other than josuagemeinde.de/uploader.php

Maybe I can post the code here:


phpupload.php

<!DOCTYPE html>
<html>
<body>

<form action="uploader.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> 

uploader.php

<?php
if(isset($_FILES['image'])){
    $errors= array();
    $file_name = $_FILES['image']['name'];
    $file_size =$_FILES['image']['size'];
    $file_tmp =$_FILES['image']['tmp_name'];
    $file_type=$_FILES['image']['type'];   
    $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
    $extensions = array("jpeg","jpg","png");         
    if(in_array($file_ext,$extensions )=== false){
        $errors[]="extension not allowed, please choose a JPEG or PNG file.";
    }
    if($file_size > 2097152){
        $errors[]='File size must be excately 2 MB';
    }                
    if(empty($errors)==true){
        move_uploaded_file($file_tmp,"images/".$file_name);
        echo "Success";
    }else{
        print_r($errors);
    }
}
?>

Hope this is helpful.

Yes, the code was exactly what I needed, thanks!

I saw that there is an error in the code that makes it not work even if your server setup was OK: The field in the HTML is called fileToUpload, but the PHP code checks for a file named image. But even when changing the form to use image as field name, it still doesn’t work.

Could you please insert a var_dump($_FILES) as the first line of the uploader.php script so I can test what error code (which is included in the array) PHP sets when uploading a file?

yikes, you are correct!

if I echo var_dump($_FILES), it gives me

array(0) { }

OK, so that’s surprising. I guess the reason for all of this is buried deep inside your web server setup. :frowning:

I’m puzzled as well.
While I was hoping for a simpler solution, I honestly suspected that the server might be setup inherently wrong. Unfortunately I have no access to the command line and such.

Maybe the the admin should do a complete wipe and start from scratch.

But a million thanks for taking the time to worry about my problems! :slight_smile:

Haha, maybe that will do it. :smiley:

You are welcome! :wink: