| @@ 288-312 (lines=25) @@ | ||
| 285 | stream_filter_append($out, 'mcrypt.tripledes', STREAM_FILTER_WRITE, $opts); |
|
| 286 | } |
|
| 287 | ||
| 288 | if ($out) { |
|
| 289 | // Read binary input stream and append it to temp file |
|
| 290 | $in = fopen($_FILES['file']['tmp_name'], "rb"); |
|
| 291 | ||
| 292 | if ($in) { |
|
| 293 | while ($buff = fread($in, 4096)) { |
|
| 294 | fwrite($out, $buff); |
|
| 295 | } |
|
| 296 | } else { |
|
| 297 | die( |
|
| 298 | '{"jsonrpc" : "2.0", |
|
| 299 | "error" : {"code": 101, "message": "Failed to open input stream."}, |
|
| 300 | "id" : "id"}' |
|
| 301 | ); |
|
| 302 | } |
|
| 303 | fclose($in); |
|
| 304 | fclose($out); |
|
| 305 | try { |
|
| 306 | unlink($_FILES['file']['tmp_name']); |
|
| 307 | } catch(Exception $e){ |
|
| 308 | print_r($e); |
|
| 309 | } |
|
| 310 | } else { |
|
| 311 | die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}'); |
|
| 312 | } |
|
| 313 | } else { |
|
| 314 | die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}'); |
|
| 315 | } |
|
| @@ 216-244 (lines=29) @@ | ||
| 213 | if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) { |
|
| 214 | // Open temp file |
|
| 215 | $out = fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab"); |
|
| 216 | if ($out) { |
|
| 217 | // Read binary input stream and append it to temp file |
|
| 218 | $in = fopen($_FILES['file']['tmp_name'], "rb"); |
|
| 219 | ||
| 220 | if ($in) { |
|
| 221 | while ($buff = fread($in, 4096)) { |
|
| 222 | fwrite($out, $buff); |
|
| 223 | } |
|
| 224 | } else { |
|
| 225 | die( |
|
| 226 | '{"jsonrpc" : "2.0", |
|
| 227 | "error" : {"code": 101, "message": "Failed to open input stream."}, |
|
| 228 | "id" : "id"}' |
|
| 229 | ); |
|
| 230 | } |
|
| 231 | fclose($in); |
|
| 232 | fclose($out); |
|
| 233 | try { |
|
| 234 | unlink($_FILES['file']['tmp_name']); |
|
| 235 | } catch(Exception $e){ |
|
| 236 | print_r($e); |
|
| 237 | } |
|
| 238 | } else { |
|
| 239 | die( |
|
| 240 | '{"jsonrpc" : "2.0", |
|
| 241 | "error" : {"code": 102, "message": "Failed to open output stream."}, |
|
| 242 | "id" : "id"}' |
|
| 243 | ); |
|
| 244 | } |
|
| 245 | } else { |
|
| 246 | die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}'); |
|
| 247 | } |
|