]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttFileHelper.class.php
Added file content to attachment put.
[timetracker.git] / WEB-INF / lib / ttFileHelper.class.php
index a45326cbc46279e55ccd62d4d47695ef97555029..b976ba14acca080f3bf07da4af8cdf6d1f742daf 100644 (file)
@@ -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;
     }