X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/137822b2c8874dd8a5b56b58774d50f09c122220..c45c90dc951017a163a3ee72bd6e26d291ceb642:/WEB-INF/lib/ttFileHelper.class.php diff --git a/WEB-INF/lib/ttFileHelper.class.php b/WEB-INF/lib/ttFileHelper.class.php index 441b8f40..7c8324b6 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,8 +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. @@ -160,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 || !$file_id || !$file_key) { + if ($error) { // Add an error from file storage facility if we have it. - $this->errors->add($file_error); + $this->errors->add($error); } return false; }