add upload
This commit is contained in:
parent
c8a454dcfa
commit
3f2e6c348a
3 changed files with 24 additions and 7 deletions
|
@ -57,6 +57,7 @@ def add(request):
|
|||
request.session.save()
|
||||
request.session.modified = True
|
||||
file = models.Item()
|
||||
file.user = request.user
|
||||
file.filename = request.POST.get('name', '')
|
||||
file.uploader = request.session.session_key
|
||||
file.save()
|
||||
|
@ -70,6 +71,7 @@ def add(request):
|
|||
if 'file' in request.FILES:
|
||||
new_file = request.FILES['file']
|
||||
file = models.Item(filename=new_file.name)
|
||||
file.user = request.user
|
||||
file.done = True
|
||||
file.file.save(new_file.name, new_file)
|
||||
os.chmod(file.file.path, 0644)
|
||||
|
@ -83,6 +85,7 @@ def add(request):
|
|||
|
||||
def index(request):
|
||||
context = RequestContext(request, {
|
||||
'anonymous': request.user.is_anonymous()
|
||||
})
|
||||
return render_to_response('index.html', context)
|
||||
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
<!DOCTYPE HTML>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title></title>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/videopdf.css"/>
|
||||
<title>generic one click host</title>
|
||||
<script src="/static/js/jquery.js" type="text/javascript"></script>
|
||||
<script src="/static/js/chunkupload.js" type="text/javascript"></script>
|
||||
<script src="/static/js/upload.js?1" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>videopdf</h1>
|
||||
{% if anonymous %}
|
||||
<div>
|
||||
you need an account
|
||||
</div>
|
||||
{% else %}
|
||||
<div>
|
||||
<div id='status'></div>
|
||||
<form id="addFile">
|
||||
<input id="file" name="file" type="file" value="Select File.." />
|
||||
<input id="upload" type="button" value="Upload" style="display: none" />
|
||||
</form>
|
||||
</div>
|
||||
{% endif %}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ TEMPLATE_LOADERS = (
|
|||
MIDDLEWARE_CLASSES = (
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
#'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
# Uncomment the next line for simple clickjacking protection:
|
||||
|
|
Loading…
Reference in a new issue