I have a script that receives large file uploads through a PUT request. These files have some on-the-fly processing when they load. Sometimes we may find that the file is not valid in the first bytes, so we are die()reporting an error. The only problem is that the client is still sending the rest of the data, which is huge waste. Is there a way to disconnect an incoming connection?
the code:
$fp = fopen('php://input', 'rb');
if( <invalid> ) {
fclose($fp);
die('Error');
}
stream_socket_shutdown looked like it could do the job, but it has no effect.
Is there any way to do this? Even if I need to write an extension just for this?
Jwood source
share