当前位置:网站首页>Logic of image uploading
Logic of image uploading
2022-07-27 05:38:00 【Csdn__ F】
import os
from django.conf import settings
# Upload logog picture
class UploadView(APIView):
def post(self, request):
# Get front-end data
file = request.data.get('file')
print(' Response to the request :',file.name)
# Splicing path
static_path = 'static/images/logos/'
file_path = os.path.join(settings.BASE_DIR, static_path)
# The final file name
file_name = os.path.join(file_path, file.name)
print(' Response of pictures :', file_name)
with open(file_name, 'wb') as f:
f.write(file.file.read())
# Return response
return Response({
'code': 200, 'msg': ' Image upload succeeded ', 'static_path': static_path})
边栏推荐
- Trying to evolve_ My first CSDN blog
- 用户登录-以及创建、验证短信验证码
- JS如何判断一个对象是否属于一个类
- 【C语言switch分支语句和循环语句】
- JS中for...of和for...in的区别
- Collation of several difficult methods in pytorch --gather & squeeze & unsqueeze
- 时间复杂度与空间复杂度
- User login - and create and verify SMS verification code
- 分享一道关于#define的选择题(内含#define在预编译时的替换规则,程序环境和预处理相关知识)
- Introduction to C language pointer
猜你喜欢
随机推荐
JS中如何判断一个对象是空对象
GCC compilation options
C语言中堆内存介绍和管理
编辑删除用户
项目登录注册思路
Day3 ---Flask 状态保持,异常处理与请求钩子
Asynchronous data SMS verification code
node 安装调试
Package JWT
Seckill system design
思考一些文件的作用
使用vertical-align不能让图片和文字垂直居中对齐
小米商城项目_注册
函数和箭头函数
SQL (MySQL) rookie tutorial knowledge
JS如何判断一个对象是否属于一个类
C语言函数入门介绍
Source code of document type full-text retrieval knowledge base management system
后台品牌管理功能实现
云E办项目之部门管理








