当前位置:网站首页>图片上传的逻辑
图片上传的逻辑
2022-07-17 05:03:00 【du fei】
import os
from django.conf import settings
# 上传logog图片
class UploadView(APIView):
def post(self, request):
# 获取前端数据
file = request.data.get('file')
print('请求的响应:',file.name)
# 拼接路径
static_path = 'static/images/logos/'
file_path = os.path.join(settings.BASE_DIR, static_path)
# 最终文件名
file_name = os.path.join(file_path, file.name)
print('图片的响应:', file_name)
with open(file_name, 'wb') as f:
f.write(file.file.read())
# 返回响应
return Response({
'code': 200, 'msg': '图片上传成功', 'static_path': static_path})
边栏推荐
猜你喜欢

Mongo Db单机版的安装和快速使用

畢設:基於Vue+Socket+Redis的分布式高並發防疫健康管理系統

Quickly master Mipi development strategy

Restclient operation document

MySQL fuzzy matching 1, 11111 similar string problems

Some concepts of ES

数据库取配置文件字段,然后进行数据处理和判断

【Lipschitz】基于matlab的Lipschitz李氏指数仿真

力扣刷题02(三数之和+最大子序和+二叉树最近公共祖先)

赚钱大师小程序【最新版5.9.9】商城/佣金即时提现/分销推广/话费充值/美团饿了么外卖
随机推荐
Embrace declarative UI
Blessing for the elderly popular short video wechat applet source code download support traffic master
【燃料电池】基于simulink的燃料电池系统控制策略仿真
使用循环语句制作登录程序
【英雄哥七月集训】第 16天:队列
Load balancer ribbon practice
solve [email protected] : `node install. Problems of js`
MySQL takes the union of two query conditions and then queries
一文了解定时任务
thinkphp 官网教程
Project team summer vacation summary 02
DSL查询文档
RestAPI
ThreadLocal线程安全示例及其原理
swagger的坑
Service end interface test - test point of interface test [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]
索引库操作基本操作
String string special interception processing according to symbols
MySQL必知必会!!!看这一篇就足够了!!!
itext修改pdf文字