zoukankan      html  css  js  c++  java
  • iframe文件上传

    views.py

    def iframe(request):
        if request.method == "GET":
            return render(request, "iframe.html")
    
        elif request.method == "POST":
            post_file = request.FILES.get("post_file")
            username = request.POST.get('username')
            file_root = os.path.join('static/upload/', post_file.name)
            with open(file_root, 'wb') as new_file:
                for item in post_file.chunks():
                    new_file.write(item)
            return HttpResponse(json.dumps("OK"))
    

    iframe.html

        <form action="{% url 'iframe' %}" method="post" target="ifm" enctype="multipart/form-data">
            <iframe id="ifm" style="display: none"></iframe>
            <input type="text" name="username" placeholder="username">
            <input type="file" name="post_file">
            <input type="submit" value="提交">
        </form>
    
    
  • 相关阅读:
    kali一些基础工具
    Yii2引入css和js文件
    My97DatePicker日期插件
    Yii2助手函数
    yii2相关前台组件
    yii2之DetailView小部件
    关于SQL_MODE的那些事
    Yii2 RBAC
    ORM介绍
    ASCII码
  • 原文地址:https://www.cnblogs.com/forsaken627/p/12521941.html
Copyright © 2011-2022 走看看