当前位置:网站首页>图片上传的逻辑
图片上传的逻辑
2022-07-27 05:02:00 【Csdn__F】
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})
边栏推荐
- Day6 --- SQLAlchemy进阶
- LeetCode之268.Missing number
- Redis lock
- Alphabetic order problem
- 商品图片的管理
- Redis transaction
- 简化JDBC的MyBits框架
- JVM Part 1: memory and garbage collection part 5 -- runtime data area virtual machine stack
- Bean的生命周期&&依赖注入*依赖自动装配
- Li Hongyi machine learning team learning punch in activity day04 - Introduction to deep learning and back propagation mechanism
猜你喜欢

Alphabetic order problem

李宏毅机器学习组队学习打卡活动day05---网络设计的技巧

数据库迁移报错解决

实用小工具: Kotlin 代码片段

用户的管理-限制

Li Hongyi machine learning team learning punch in activity day03 --- error and gradient decline

创建项目 实现登录注册,生成jwt,发送验证码

MQ set expiration time, priority, dead letter queue, delay queue

Message reliability processing

How to quickly and effectively solve the problem of database connection failure
随机推荐
B1022 a+b in d-ary
B1030 完美数列
Student management system
Sparse array → saving and continuation of Gobang
B1031 check ID card
B1025 反转链表*******
Notes Series docker installation PostgreSQL 14
JVM Part 1: memory and garbage collection part 8 - runtime data area - Method area
[CSAPP] Application of bit vectors | encoding and byte ordering
SQL database → constraint → design → multi table query → transaction
李宏毅机器学习组队学习打卡活动day03---误差和梯度下降
2022 Zhengzhou light industry Freshmen's competition topic - I won't say if I'm killed
Li Hongyi machine learning team learning punch in activity day05 --- skills of network design
LeetCode之268.Missing number
后台实现sku 管理
注册功能实现
Day4 --- Flask 蓝图与Rest-ful
[optical flow] - data format analysis, flowwarp visualization
Collation of several difficult methods in pytorch --gather & squeeze & unsqueeze
What should test / development programmers over 35 do? Many objective factors