I'm using the Valums File Uploader to upload files using XHR. The script I use works great on my live server while it fails on my local server. The code concerned is following:
$input = fopen("php://input", "r");
$temp = tmpfile();
$realSize = stream_copy_to_stream($input, $temp);
fclose($input);
if ($realSize != $this->getSize()){
return false;
}
$target = fopen($path, "w");
fseek($temp, 0, SEEK_SET);
stream_copy_to_stream($temp, $target);
fclose($target);
chmod($path, 0644);
The thing is that $realSize is empty on my local server while it does have a value on my live server. So on the local server it breaks at the size check. I suspect it is a server configuration issue, but I don't exactly know what to look for. Could someone point me into the right direction?
I've found the culprit. tmpfile() wasn't able to create the temp file because the rights on the temp folder didn't allow write. Found the location of the temp folder using sys_get_temp_dir()
Made this directory writable and all was GO again!