Problem uploading image on the server

Hey folks,

If someone could give a little hint on this issue I am having:
I moved my site to the server since then I am unable to upload any image, the server complains that:

Backend log: PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0\n, referer…

Backend log: PHP Notice: Unknown: file created in the system’s temporary directory in Unknown on line 0\n…

Backend log: PHP Warning: Unknown: open_basedir restriction in effect. File(/tmp) is not within the allowed path(s)…

I contacted the hosting provider and I got an answer saying if I could use a different path:

" 1) Please, do not use / tmp folder. It is recommended to use / data / www / domain / mysite.com/tmp (and this is the default value of PHP variables: upload_tmp_dir and sys_temp_dir) - so if your CMS Use These variables, it should be fine. Maybe you have somewhere in the config file the option to manually configure it."

Does anyone have some similar issue? it would it be configurable from Kirby side, or I cannot do that and I need to update on the hosting side?

Many thanks

Hm, I think Kirby uses whatever is set by your system. What is set in your php.ini?

You could also test if you can upload files without Kirby, with a basic PHP upload script.

Does the / data / www / domain / mysite.com/tmp folder exist?

the structure on the hosting is like that:

logs

  • tmp/
  • www /
    • assets
    • content
    • kirby
    • site
    • …

I believe I should have the /tmp folder on the same level as the kirby folders

No, it doesn’t matter where this folder is located as long as PHP knows about it. But check your php.ini if this folder is set as your temp folder (upload_tmp_dir = )and also check if it is writable.

on php.info, it is /temp

The hosting support keep saying that:

“this is an absolute path to your tmp directory. If you specify / tmp in your applications, it tries to use the system / tmp folder, not tmp folder under your domain.”

Have you tried to set the upload_tmp_dir in php.ini to the folder they are telling you to use? The support doesn’t seem to be too helpful. Who is your provider?

the client has some local provider, I don’t even have access to php.ini, however, **phpinfo();**m I can see:

upload_tmp_dir /data/www/domeny/my-domain.com/tmp

should I check another value? Google, I found a similar issue but with Wordpress,

is there somewhere I could set this? I helpless, not sure where to fix it.

Thanks.

I tested changing the upload_tmp_dir in php.ini and all uploads used the new location as expected.

So that means if that folder is correctly set, as your PHP info seems to suggest, Kirby should pick it up (or in fact any PHP process).

As regards the open_basedir directive, you can set that everywhere, e.g. in your php.ini (since it doesn’t exist, create one) or you can also try to set it in the index.php.