aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-12-17 16:22:13 -0800
committerredmatrix <redmatrix@redmatrix.me>2015-12-17 16:22:13 -0800
commit62a60e554235c66c88955d16134c874ad560bf72 (patch)
treed50052b9dc13312d9d4b84d0897bba424686a811 /include
parent539d06f02dc31a3b16d8c0cfa0cc60b64a78088e (diff)
downloadvolse-hubzilla-62a60e554235c66c88955d16134c874ad560bf72.tar.gz
volse-hubzilla-62a60e554235c66c88955d16134c874ad560bf72.tar.bz2
volse-hubzilla-62a60e554235c66c88955d16134c874ad560bf72.zip
more work on media uploads via api
Diffstat (limited to 'include')
-rw-r--r--include/api.php32
-rw-r--r--include/attach.php4
2 files changed, 27 insertions, 9 deletions
diff --git a/include/api.php b/include/api.php
index 5c72a2d0c..5053977c5 100644
--- a/include/api.php
+++ b/include/api.php
@@ -859,15 +859,29 @@ require_once('include/api_auth.php');
$_REQUEST['type'] = 'wall';
if(x($_FILES,'media')) {
- $num_uploads = count($_FILES['media']['name']);
- for($x = 0; $x < $num_uploads; $x ++) {
- $_FILES['userfile'] = array();
- $_FILES['userfile']['name'] = $_FILES['media']['name'][$x];
- $_FILES['userfile']['type'] = $_FILES['media']['type'][$x];
- $_FILES['userfile']['tmp_name'] = $_FILES['media']['tmp_name'][$x];
- $_FILES['userfile']['error'] = $_FILES['media']['error'][$x];
- $_FILES['userfile']['size'] = $_FILES['media']['size'][$x];
-
+ if(is_array($_FILES['media']['name'])) {
+ $num_uploads = count($_FILES['media']['name']);
+ for($x = 0; $x < $num_uploads; $x ++) {
+ $_FILES['userfile'] = array();
+ $_FILES['userfile']['name'] = $_FILES['media']['name'][$x];
+ $_FILES['userfile']['type'] = $_FILES['media']['type'][$x];
+ $_FILES['userfile']['tmp_name'] = $_FILES['media']['tmp_name'][$x];
+ $_FILES['userfile']['error'] = $_FILES['media']['error'][$x];
+ $_FILES['userfile']['size'] = $_FILES['media']['size'][$x];
+
+ // upload each image if we have any
+ $_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo
+ require_once('mod/wall_attach.php');
+ $a->data['api_info'] = $user_info;
+ $media = wall_attach_post($a);
+
+ if(strlen($media)>0)
+ $_REQUEST['body'] .= "\n\n" . $media;
+ }
+ }
+ else {
+ // AndStatus doesn't present media as an array
+ $_FILES['userfile'] = $_FILES['media'];
// upload each image if we have any
$_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo
require_once('mod/wall_attach.php');
diff --git a/include/attach.php b/include/attach.php
index 20e8b7444..8595d5d86 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -503,6 +503,10 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
}
}
+ // AndStatus sends jpegs with a non-standard mimetype
+ if($type === 'image/jpg')
+ $type = 'image/jpeg';
+
$existing_size = 0;
if($options === 'replace') {