小编tom*_*joy的帖子

Django文件上传进度

我已经使用Django文件上传进度流程获取进度但收到错误pliks.upload" does not define a "UploadProgressCachedHandler" upload handler backend.

我遵循的步骤是

1)创建文件夹上传并向其添加文件上载处理程序(UploadProgressCachedHandler.py).

    from django.core.files.uploadhandler import FileUploadHandler
    from django.core.cache import cache
    class UploadProgressCachedHandler(FileUploadHandler):
        """
        Tracks progress for file uploads.
        The http post request must contain a header or query parameter, 'X-Progress-ID'
        which should contain a unique string to identify the upload to be tracked.

        Copied from:
        http://djangosnippets.org/snippets/678/

        See views.py for upload_progress function...
        """

        def __init__(self, request=None):
            super(UploadProgressCachedHandler, self).__init__(request)
            self.progress_id = None
            self.cache_key = None

        def handle_raw_input(self, input_data, META, content_length, boundary, …
Run Code Online (Sandbox Code Playgroud)

django file-upload progress

5
推荐指数
1
解决办法
4134
查看次数

Javascript在div中查找所选文本的出现位置

我有一个字符串有一个单词五次.如果我选​​择了你好它应该返回4

 <div id="content">hello hai hello hello hello</div>
Run Code Online (Sandbox Code Playgroud)

获取选定的文本脚本

<script>
 if(window.getSelection){
   t = window.getSelection();
 }else if(document.getSelection){
   t = document.getSelection();
 }else if(document.selection){
   t =document.selection.createRange().text;
 }
 </script>
Run Code Online (Sandbox Code Playgroud)

如果我选择 hai它应该返回1.

如果我选择 hello hai它应该返回1.请帮忙.

javascript indexing

3
推荐指数
1
解决办法
5898
查看次数

标签 统计

django ×1

file-upload ×1

indexing ×1

javascript ×1

progress ×1