質問編集履歴
1
割愛させていただいていたCODEの部分も表示させていただきました
test
CHANGED
File without changes
|
test
CHANGED
@@ -47,3 +47,95 @@
|
|
47
47
|
ご助力いただけますと幸いでございます。
|
48
48
|
|
49
49
|
何卒よろしくお願いいたします。
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
----------------------------------------------------
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
割愛させていただいていた部分のCODEも表示させていただきました。
|
58
|
+
|
59
|
+
```python
|
60
|
+
|
61
|
+
#!/usr/bin/env python
|
62
|
+
|
63
|
+
# -*- coding:utf-8 -*-
|
64
|
+
|
65
|
+
import cgi
|
66
|
+
|
67
|
+
import cgitb
|
68
|
+
|
69
|
+
import os, sys
|
70
|
+
|
71
|
+
cgitb.enable()
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
try:
|
76
|
+
|
77
|
+
import msvcrt
|
78
|
+
|
79
|
+
msvcrt.setmode(0, os.O_BINARY)
|
80
|
+
|
81
|
+
msvcrt.setmode(1, os.O_BINARY)
|
82
|
+
|
83
|
+
except ImportError:
|
84
|
+
|
85
|
+
pass
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
result = 'DUMMY'
|
90
|
+
|
91
|
+
form = cgi.FieldStorage()
|
92
|
+
|
93
|
+
#if form.has_key('file'):
|
94
|
+
|
95
|
+
if 'file' in form:
|
96
|
+
|
97
|
+
item = form['file']
|
98
|
+
|
99
|
+
if item.file:
|
100
|
+
|
101
|
+
# fout = file(os.path.join('/tmp', item.filename), 'wb')
|
102
|
+
|
103
|
+
fout = open(os.path.join('C:\server\cgi-bin\write', item.filename), 'wb')
|
104
|
+
|
105
|
+
while True:
|
106
|
+
|
107
|
+
chunk = item.file.read(1000000)
|
108
|
+
|
109
|
+
if not chunk:
|
110
|
+
|
111
|
+
break
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
fout.write(chunk)
|
116
|
+
|
117
|
+
fout.close()
|
118
|
+
|
119
|
+
result = 'upload is done'
|
120
|
+
|
121
|
+
#result = "アップロード"
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
f = open("hosi.jpg","rb")
|
126
|
+
|
127
|
+
print("Content-Type: text/html")
|
128
|
+
|
129
|
+
# print("Content-Type: image/jpeg")
|
130
|
+
|
131
|
+
print("")
|
132
|
+
|
133
|
+
print("<html><body>")
|
134
|
+
|
135
|
+
print(f.read())
|
136
|
+
|
137
|
+
print(result)
|
138
|
+
|
139
|
+
print("</body><html>")
|
140
|
+
|
141
|
+
```
|