PHP tmpfile() returns false

前端 未结 4 1985
情书的邮戳
情书的邮戳 2020-12-10 17:42

I\'ve got an image upload script which was previously working. It\'s now broken, and I\'ve traced the problem down to one line:

$temp = tmpfile();
// $temp          


        
相关标签:
4条回答
  • 2020-12-10 18:15

    It might be a problem with permissions. Use sys_get_temp_dir() to see where the temp file will be created and make sure php has access to write there.

    0 讨论(0)
  • 2020-12-10 18:18

    tmpfile() returns false if it is unable to create the temporary file. Make sure your tmp folder is writable and try and check what sys_get_temp_dir() function returns.

    0 讨论(0)
  • 2020-12-10 18:25

    In my case, the folder it was trying to create the file in had temp files ranging all the way up to tmpFFFF.tmp. After moving those temp files away from the folder, it started back at tmp1.tmp.

    0 讨论(0)
  • 2020-12-10 18:31

    First, enable all PHP warnings to see if it is telling you something.

    Second, check your temp folder and make sure PHP has write access to it. It's possible that certain "safe mode" restrictions (base dirs, etc) are preventing access.

    0 讨论(0)
提交回复
热议问题