当前位置: 动力学知识库 > 问答 > 编程问答 >

django - searching users computer for music and video files from browser

问题描述:

I am currently making a website and one of the functions I want is to add a user's music and video files to their library automatically by searching for the path of them on their hard drive and adding them to a database.

import os

for root, dirs, files in os.walk("/mydir"):

for file in files:

if file.endswith(".txt"):

print(os.path.join(root, file))

I know I can use this python script to search on my own server but is it possible to make it search a user's computer with the correct permissions?

网友答案:

You definitly cannot access local filesystem of your users. It is a security matter.

You can read more at this related question : Reading files from hard drive with javascript

What you can do by the way is limiting the type of file you can upload with the accept attribute :

<input id="fileSelect" type="file" accept=".txt" /> 
分享给朋友:
您可能感兴趣的文章:
随机阅读: