|
@@ -106,8 +106,9 @@ class Images |
|
@@ -106,8 +106,9 @@ class Images |
106
|
/**
|
106
|
/**
|
107
|
* 图片上传
|
107
|
* 图片上传
|
108
|
* @param string $name 文件表单name, 即用于$_FILES[$name]
|
108
|
* @param string $name 文件表单name, 即用于$_FILES[$name]
|
|
|
109
|
+ * @param string $path
|
109
|
*/
|
110
|
*/
|
110
|
- public static function saveImage($name)
|
111
|
+ public static function saveImage($name, $path = 'suggest')
|
111
|
{
|
112
|
{
|
112
|
if (empty($_FILES[$name])) {
|
113
|
if (empty($_FILES[$name])) {
|
113
|
return array();
|
114
|
return array();
|
|
@@ -124,7 +125,7 @@ class Images |
|
@@ -124,7 +125,7 @@ class Images |
124
|
$images[$files['name']] = $files['tmp_name'];
|
125
|
$images[$files['name']] = $files['tmp_name'];
|
125
|
}
|
126
|
}
|
126
|
|
127
|
|
127
|
- return self::uploadStreamImage($images);
|
128
|
+ return self::uploadStreamImage($images, $path);
|
128
|
}
|
129
|
}
|
129
|
|
130
|
|
130
|
/**
|
131
|
/**
|
|
@@ -132,9 +133,10 @@ class Images |
|
@@ -132,9 +133,10 @@ class Images |
132
|
*
|
133
|
*
|
133
|
* @param string | array(filename => absolute file path) $file
|
134
|
* @param string | array(filename => absolute file path) $file
|
134
|
* url:http://upload.static.yohobuy.com?project=sns&fileData=xxx
|
135
|
* url:http://upload.static.yohobuy.com?project=sns&fileData=xxx
|
|
|
136
|
+ * @param string $path
|
135
|
* @return mixed
|
137
|
* @return mixed
|
136
|
*/
|
138
|
*/
|
137
|
- public static function uploadStreamImage($file)
|
139
|
+ public static function uploadStreamImage($file, $path = 'suggest')
|
138
|
{
|
140
|
{
|
139
|
$end = "\r\n";
|
141
|
$end = "\r\n";
|
140
|
$twoHyphens = "--";
|
142
|
$twoHyphens = "--";
|
|
@@ -158,7 +160,7 @@ class Images |
|
@@ -158,7 +160,7 @@ class Images |
158
|
$stream .= $twoHyphens . $boundary . $end;
|
160
|
$stream .= $twoHyphens . $boundary . $end;
|
159
|
$stream .="Content-Disposition: form-data; " . "name=\"project\"" . $end;
|
161
|
$stream .="Content-Disposition: form-data; " . "name=\"project\"" . $end;
|
160
|
$stream .= $end;
|
162
|
$stream .= $end;
|
161
|
- $stream .= 'suggest'; //project sns
|
163
|
+ $stream .= $path; //project sns
|
162
|
$stream .= $end;
|
164
|
$stream .= $end;
|
163
|
$stream .= $twoHyphens . $boundary . $twoHyphens . $end;
|
165
|
$stream .= $twoHyphens . $boundary . $twoHyphens . $end;
|
164
|
$opts = array(
|
166
|
$opts = array(
|
|
@@ -177,14 +179,14 @@ class Images |
|
@@ -177,14 +179,14 @@ class Images |
177
|
if (count($file) == 1 || !is_array($file)) {
|
179
|
if (count($file) == 1 || !is_array($file)) {
|
178
|
$imgRelUrl = current($result['data']['imagesList']);
|
180
|
$imgRelUrl = current($result['data']['imagesList']);
|
179
|
$imgList['imgList'][] = array(
|
181
|
$imgList['imgList'][] = array(
|
180
|
- 'imgUrl' => self::getSourceUrl($imgRelUrl, 'suggest') . $imgExtra,
|
182
|
+ 'imgUrl' => self::getSourceUrl($imgRelUrl, $path) . $imgExtra,
|
181
|
'imgRelUrl' => $imgRelUrl
|
183
|
'imgRelUrl' => $imgRelUrl
|
182
|
);
|
184
|
);
|
183
|
} else {
|
185
|
} else {
|
184
|
$img = array();
|
186
|
$img = array();
|
185
|
foreach ($result['data']['imagesList'] as $val) {
|
187
|
foreach ($result['data']['imagesList'] as $val) {
|
186
|
$img = array();
|
188
|
$img = array();
|
187
|
- $img['imgUrl'] = self::getSourceUrl($val, 'suggest') . $imgExtra;
|
189
|
+ $img['imgUrl'] = self::getSourceUrl($val, $path) . $imgExtra;
|
188
|
$img['imgRelUrl'] = $val;
|
190
|
$img['imgRelUrl'] = $val;
|
189
|
$imgList['imgList'][] = $img;
|
191
|
$imgList['imgList'][] = $img;
|
190
|
}
|
192
|
}
|