|
@@ -19,10 +19,8 @@ trait AttachmentHelper
|
|
* @param array $mimeType 文件mime类型限制,默认不限
|
|
* @param array $mimeType 文件mime类型限制,默认不限
|
|
* @return array|string|int 返回:md5字串|ErrorCode或[md5字串|ErrorCode]
|
|
* @return array|string|int 返回:md5字串|ErrorCode或[md5字串|ErrorCode]
|
|
*/
|
|
*/
|
|
- public function uploadAttachment(Request $request, $key, $tag = 'files', $size = 2 * 1024 * 1024, array $mimeType = []) {
|
|
|
|
- \Log::info("key:".$request->hasFile($key));
|
|
|
|
|
|
+ public function uploadAttachment(Request $request, $key, $tag = 'files', $size = 10 * 1024 * 1024, array $mimeType = []) {
|
|
if ($request->hasFile($key)) {
|
|
if ($request->hasFile($key)) {
|
|
- \Log::info("key:".$key);
|
|
|
|
$rel_path = '/upload/' . $tag . '/' . date('Ymd');
|
|
$rel_path = '/upload/' . $tag . '/' . date('Ymd');
|
|
$path = public_path() . $rel_path;
|
|
$path = public_path() . $rel_path;
|
|
if (!file_exists($path)) {
|
|
if (!file_exists($path)) {
|
|
@@ -53,6 +51,7 @@ trait AttachmentHelper
|
|
}
|
|
}
|
|
|
|
|
|
$fileMimeType = $file->getMimeType();
|
|
$fileMimeType = $file->getMimeType();
|
|
|
|
+ \Log::info("fileMimeType:".$fileMimeType);
|
|
if (!empty($mimeType) && !in_array($fileMimeType, $mimeType)) {
|
|
if (!empty($mimeType) && !in_array($fileMimeType, $mimeType)) {
|
|
$result[$idx] = ErrorCode::ATTACHMENT_MIME_NOT_ALLOWED;
|
|
$result[$idx] = ErrorCode::ATTACHMENT_MIME_NOT_ALLOWED;
|
|
continue;
|
|
continue;
|