PHP tmpfile () returns false

I have a downloaded picture script that worked previously. Now it is broken, and I traced the problem to one line:

$temp = tmpfile(); // $temp === false 

The tmpfile () function returns false. I can’t understand why. It's hard for me to wade through Google on this one.

The script is only broken on my local test environment, OSX 10.6.7, running MAMP 1.9.5. Fortunately, the site is working fine.

+6
source share
4 answers

tmpfile () returns false if it cannot create a temporary file. Make sure your tmp folder is writable, and try checking that sys_get_temp_dir() returns.

+11
source

This may be a permission issue. Use sys_get_temp_dir() to see where the temp file will be created, and make sure php has write access there.

+3
source

Turn on all PHP warnings first to see if it tells you something.

Secondly, check your temporary folder and make sure that PHP has write access to it. It is possible that certain "safe mode" restrictions (basic disks, etc.) prevent access.

0
source

In my case, there were temporary files in the folder in which he was trying to create the file, up to tmpFFFF.tmp. After you moved these temporary files from the folder, it returned to tmp1.tmp again.

0
source

Source: https://habr.com/ru/post/889970/


All Articles