I have a website written in PHP and on this website, I use Andrew Valums’ “Ajax Upload” JavaScript, which uses XHR for uploading files in browsers that support it and a hidden iframe for the other browsers. When XHR is used, my PHP script makes sure stream_copy_to_stream($source, $dest) is equal to $_SERVER['CONTENT_LENGTH'] (this is how the sample PHP script was). Even though I wasn’t sure of the reasoning for this check when I implemented this, I left the code there anyway. It turns out there have been a few times when users have uploaded files and those two values have been different. I’m wondering what causes this. I’m guessing it’s a network timeout, but is this the only thing that could cause it? Also, is there ever a time that $_SERVER['CONTENT_LENGTH'] would not be set?
Thanks!
Content-Lengthheader.$_SERVER['CONTENT_LENGTH']is unset if noContent-Lengthheader is set. This should happen only whenTransfer-Encoding: chunked.