-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
581 additions
and
114 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.11.7 on 2017-11-14 02:58 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('freeStyle', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='storeImg', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('img', models.ImageField(upload_to='img')), | ||
('name', models.CharField(max_length=20)), | ||
], | ||
), | ||
] |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
//下面用于图片上传预览功能 | ||
function setImagePreview(avalue) { | ||
var docObj=document.getElementById("doc"); | ||
|
||
var imgObjPreview=document.getElementById("preview"); | ||
if(docObj.files &&docObj.files[0]) | ||
{ | ||
//火狐下,直接设img属性 | ||
imgObjPreview.style.display = 'block'; | ||
imgObjPreview.style.width = '150px'; | ||
imgObjPreview.style.height = '180px'; | ||
|
||
//火狐7以上版本不能用上面的getAsDataURL()方式获取,需要一下方式 | ||
imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]); | ||
} | ||
else | ||
{ | ||
//IE下,使用滤镜 | ||
docObj.select(); | ||
var imgSrc = document.selection.createRange().text; | ||
var localImagId = document.getElementById("localImag"); | ||
//必须设置初始大小 | ||
localImagId.style.width = "150px"; | ||
localImagId.style.height = "180px"; | ||
//图片异常的捕捉,防止用户修改后缀来伪造图片 | ||
try{ | ||
localImagId.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)"; | ||
localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc; | ||
} | ||
catch(e) | ||
{ | ||
alert("您上传的图片格式不正确,请重新选择!"); | ||
return false; | ||
} | ||
imgObjPreview.style.display = 'none'; | ||
document.selection.empty(); | ||
} | ||
return true; | ||
} | ||
|
||
function FW(event){ | ||
alert('hah'); | ||
var input = document.getElementById('doc'); | ||
var reader = new FileReader(); | ||
var csrf = document.getElementsByTagName('input')[0].value; | ||
console.log(csrf); | ||
// var dataAF = {}; | ||
// dataAF.img = reader.result; | ||
// data.csrfmiddlewaretoken = csrf; | ||
reader.onload = function(){ | ||
var dataAF = {}; | ||
dataAF.img = reader.result; | ||
dataAF.csrfmiddlewaretoken = csrf; | ||
|
||
httpHelper({ | ||
type:'post', | ||
async:'true', | ||
data:dataAF, | ||
url:'/upload/', | ||
success:function(){ | ||
//上传成功 | ||
}, | ||
error:function(){ | ||
//上传失败 | ||
} | ||
}); | ||
}; | ||
reader.readAsBinaryString(input.files[0]); | ||
}; | ||
function httpHelper(params) { | ||
var request; | ||
if(XMLHttpRequest) | ||
request=new XMLHttpRequest(); | ||
else | ||
request=new ActiveXObject("Microsoft.XMLHTTP"); | ||
request.onreadystatechange = function () { | ||
if (request.readyState == 4) { | ||
if (request.status == 200) { | ||
if (params.success) | ||
params.success(request.responseText); | ||
} | ||
else if (parseInt(request.status / 100) == 4) { | ||
if (params.error) | ||
params.error(request.responseText); | ||
} | ||
} | ||
} | ||
request.open(params.type, params.url, params.async); | ||
try { | ||
request.send(params.data||null); | ||
} catch (e) { | ||
if (params.error) | ||
params.error(request.responseText); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% for img in imgs %} | ||
<img src="{{ img.img.url }}" /> | ||
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,54 @@ | ||
<!--<!DOCTYPE html>--> | ||
<!--<html lang="en">--> | ||
<!--<head>--> | ||
<!--<meta charset="UTF-8">--> | ||
<!--<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />--> | ||
|
||
<!--<title>Success</title>--> | ||
<!--</head>--> | ||
<!--<body>--> | ||
<!--<h1>Good boy(girl)<br/>--> | ||
<!--See you later.</h1>--> | ||
<!--</body>--> | ||
<!--</html>--> | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" /> | ||
|
||
<title>Success</title> | ||
<title>uploadImg</title> | ||
{% load staticfiles %} | ||
<script src="{% static "js/vendor/jquery-1.12.0.min.js" %}"></script> | ||
<script src="{% static "js/upload.js" %}"></script> | ||
</head> | ||
<body> | ||
<h1>Good boy(girl)<br/> | ||
See you later.</h1> | ||
<div> | ||
{% csrf_token %} | ||
<table width="100%" border="0" cellspacing="0" cellpadding="0"> | ||
<tbody> | ||
<tr> | ||
<td height="101" align="center"> | ||
<div id="localImag"> | ||
|
||
<img id="preview" src="" width="150" height="180" alt="placeholder" | ||
style="display: block; width: 150px; height: 180px;"> | ||
|
||
</div> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td align="center" style="padding-top:10px;"> | ||
|
||
<input type="file" name="file" id="doc" style="width:150px;" onchange="setImagePreview()"> | ||
|
||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<input type="button" value="upload" onclick="FW()"/> | ||
</div> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" /> | ||
|
||
<title>uploadImg</title> | ||
{% load staticfiles %} | ||
<script src="{% static "js/vendor/jquery-1.12.0.min.js" %}"></script> | ||
<script src="{% static "js/upload.js" %}"></script> | ||
</head> | ||
<body> | ||
<table width="100%" border="0" cellspacing="0" cellpadding="0"> | ||
<tbody> | ||
<tr> | ||
<td height="101" align="center"> | ||
<div id="localImag"> | ||
|
||
<img id="preview" src="http://pic.cnblogs.com/face/1023040/20160923152523.png" width="150" height="180" style="display: block; width: 150px; height: 180px;"> | ||
|
||
</div> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td align="center" style="padding-top:10px;"> | ||
|
||
<input type="file" name="file" id="doc" style="width:150px;" onchange="setImagePreview();"> | ||
|
||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<form method="POST" enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
<input type="file" name="img"> | ||
<button type="submit">上传</button> | ||
</form> |