Skip to content

Commit

Permalink
Test for multipart seems reversed. Didn't work, now it does.
Browse files Browse the repository at this point in the history
  • Loading branch information
odinho committed Oct 5, 2012
1 parent a66b71d commit e26eecd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/upload.php
Expand Up @@ -56,7 +56,7 @@
if (!file_exists($targetDir))
@mkdir($targetDir);

// Remove old temp files
// Remove old temp files
if ($cleanupTargetDir && is_dir($targetDir) && ($dir = opendir($targetDir))) {
while (($file = readdir($dir)) !== false) {
$tmpfilePath = $targetDir . DIRECTORY_SEPARATOR . $file;
Expand All @@ -70,7 +70,7 @@
closedir($dir);
} else
die('{"jsonrpc" : "2.0", "error" : {"code": 100, "message": "Failed to open temp directory."}, "id" : "id"}');


// Look for the content type header
if (isset($_SERVER["HTTP_CONTENT_TYPE"]))
Expand All @@ -80,7 +80,7 @@
$contentType = $_SERVER["CONTENT_TYPE"];

// Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
if (strpos($contentType, "multipart") !== false) {
if (!strstr($contentType, "multipart")) {
if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
// Open temp file
$out = fopen("{$filePath}.part", $chunk == 0 ? "wb" : "ab");
Expand Down Expand Up @@ -121,12 +121,12 @@

// Check if file has been uploaded
if (!$chunks || $chunk == $chunks - 1) {
// Strip the temp .part suffix off
// Strip the temp .part suffix off
rename("{$filePath}.part", $filePath);
}


// Return JSON-RPC response
die('{"jsonrpc" : "2.0", "result" : null, "id" : "id"}');

?>
?>

0 comments on commit e26eecd

Please sign in to comment.