|
|
@@ -25,16 +25,13 @@ class UploadController extends BaseController
|
|
|
if (!is_uploaded_file($file['tmp_name'])) {
|
|
|
util::fail('please upload img');
|
|
|
}
|
|
|
- $mainId = $this->mainId;
|
|
|
- if (intval($mainId) == 0) {
|
|
|
- Yii::error('------- lose token -------');
|
|
|
- noticeUtil::push('save-file 无token进行上传文件');
|
|
|
- return;
|
|
|
+ $userId = $this->userId;
|
|
|
+ if (empty($userId)) {
|
|
|
+ noticeUtil::push("上传时没有找到userId", '15280215347');
|
|
|
}
|
|
|
- $shopId = $this->shopId;
|
|
|
$month = date("Ym");
|
|
|
$date = date("d");
|
|
|
- $path = dirUtil::getImgUploadDir() . "/wxAvatar/{$mainId}/{$shopId}/{$month}/{$date}/";
|
|
|
+ $path = dirUtil::getImgUploadDir() . "/wxAvatar/$userId/{$month}/{$date}/";
|
|
|
// 检查目录是否存在,如果不存在则尝试创建。
|
|
|
// 使用 @ 抑制 mkdir 在目录已存在时(并发导致)的 warning。
|
|
|
// 如果 mkdir 失败,则再次检查目录是否存在,以区分是并发创建成功还是真的创建失败。
|
|
|
@@ -45,7 +42,7 @@ class UploadController extends BaseController
|
|
|
$newFile = $preFileName . ".jpg";
|
|
|
$fullPathFile = $path . $newFile;
|
|
|
if (move_uploaded_file($file['tmp_name'], $fullPathFile)) {
|
|
|
- $img = "{$uploadPath}/wxAvatar/{$mainId}/{$shopId}/{$month}/{$date}/" . $newFile;
|
|
|
+ $img = "{$uploadPath}/wxAvatar/$userId/{$month}/{$date}/" . $newFile;
|
|
|
oss::uploadImage($img, $fullPathFile);
|
|
|
$data = business::formatUploadImg($img);
|
|
|
$data['shortUrl'] = $img;
|