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 === false
The tmpfile() function is returning false. I can't seem to figure out why. I'm having a hard time wading through Google on this one.
The script it only broken on my local test environment, OSX 10.6.7, running MAMP 1.9.5. Fortunately the live site is working fine.
The temporary file is automatically removed when it is closed with fclose(), or when the script ends. The tmpfile() function returns Boolean False but many times it happens that it returns a non-Boolean value which evaluates to False.
The tmpfile() function creates a temporary file with a unique name in read-write (w+) mode. Note: The file is automatically removed when closed, with fclose() or when the script ends. Tip: See also the tempnam() function.
Definition and UsageThe tempnam() function creates a temporary file with a unique name in the specified directory. Note: If the specified directory does not exist, tempnam() may generate a file in the system's temporary directory.
php stores all temporary files, that includes uploaded files, in the temporary files directory as specified in the php. ini.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With