X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/699d174c8cd3dd88265826a6b69c7fae3b62e0a8..024e938728d2b436f1f048531d8fd00a246920c6:/WEB-INF/lib/ttFileHelper.class.php diff --git a/WEB-INF/lib/ttFileHelper.class.php b/WEB-INF/lib/ttFileHelper.class.php index a45326cb..b976ba14 100644 --- a/WEB-INF/lib/ttFileHelper.class.php +++ b/WEB-INF/lib/ttFileHelper.class.php @@ -85,8 +85,14 @@ class ttFileHelper { curl_close($ch); $result_array = json_decode($result, true); - if ($result_array && $result_array['id'] && $result_array['key']) { - + if (!$result_array) { + $this->errors->add($i18n->get('error.file_storage')); + } + else if ($result_array['error']) { + // Add an error from file storage facility if we have it. + $this->errors->add($result_array['error']); + } + else if ($result_array['id'] && $result_array['key']) { $this->site_id = $result_array['id']; $this->site_key = $result_array['key']; @@ -129,7 +135,7 @@ class ttFileHelper { 'user_key' => urlencode($fields['user_key']), // May be null. 'file_name' => urlencode($fields['file_name']), 'description' => urlencode($fields['description']), - // TODO: add file content here, too. Will this work for large files? + 'content' => urlencode(file_get_contents($_FILES['newfile']['tmp_name'])) ); // url-ify the data for the POST. @@ -159,12 +165,12 @@ class ttFileHelper { $result_array = json_decode($result, true); $file_id = (int) $result_array['file_id']; $file_key = $result_array['file_key']; - $file_error = $result_array['file_error']; + $error = $result_array['error']; if (!$file_id || !$file_key) { - if ($file_error) { + if ($error) { // Add an error from file storage facility if we have it. - $this->errors->add($file_error); + $this->errors->add($error); } return false; }