@@ -189,20 +189,29 @@ public function upload($context, $upload_file) {
189
189
$ ch =curl_init ();
190
190
curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , true );
191
191
curl_setopt ($ ch , CURLOPT_URL , $ url );
192
+
193
+ // send file
194
+ curl_setopt ($ ch , CURLOPT_POST , true );
195
+
196
+ if (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 5 ) {
197
+ $ attachments = realpath ($ upload_file );
198
+ $ filename = basename ($ upload_file );
192
199
193
- /* CURLFile support PHP 5.5
194
- $cf = new \CURLFile(realpath($upload_file), 'image/png', $upload_file);
195
- $this->log->addDebug('CURLFile=' . var_export($cf, true));
196
- */
200
+ curl_setopt ($ ch , CURLOPT_POSTFIELDS ,
201
+ array ('file ' => '@ ' . $ attachments . ';filename= ' . $ filename ));
202
+
203
+ $ this ->log ->addDebug ('using legacy file upload ' );
204
+ } else {
205
+ // CURLFile require PHP > 5.5
206
+ $ attachments = new \CURLFile (realpath ($ upload_file ));
207
+ $ attachments ->setPostFilename ( basename ($ upload_file ));
208
+
209
+ curl_setopt ($ ch , CURLOPT_POSTFIELDS ,
210
+ array ('file ' =>$ attachments ));
197
211
198
- $ attachments = realpath ( $ upload_file );
199
- $ filename = basename ( $ upload_file );
212
+ $ this -> log -> addDebug ( ' using CURLFile= ' . var_export ( $ attachments , true ) );
213
+ }
200
214
201
- // send file
202
- curl_setopt ($ ch , CURLOPT_POST , true );
203
- curl_setopt ($ ch , CURLOPT_POSTFIELDS ,
204
- array ('file ' => '@ ' . $ attachments . ';filename= ' . $ filename ));
205
-
206
215
curl_setopt ($ ch , CURLOPT_USERPWD , "$ this ->username : $ this ->password " );
207
216
208
217
curl_setopt ($ ch , CURLOPT_SSL_VERIFYHOST , $ this ->CURLOPT_SSL_VERIFYHOST );
0 commit comments