【发布时间】:2014-04-15 00:27:48
【问题描述】:
对于我的论坛,我尝试使用 html 上传文件:
<form action="profiles.py" method="post">
<label class="labelOne" for="pics">Change your Profile pic </label>
<input type="file" name="uploadField" />
我的 python 函数获取该文件,在 userprofiles 下创建一个文件,并将数据写入其中:
file = open('../data/accounts/userprofiles/'+str(form['name'].value)+'/'+'profilepics', 'w+')
file.write(str(form.getvalue('uploadField')))
file.close()
所以,如果我希望 burger.jpg 成为我的图片,我上传它,python 会使用它并使用 w+ 创建一个名为 burger.jpg 的文件,然后将数据写入其中(应该是图片)。
但是由于某种原因,我没有得到图像。
接下来我应该尝试什么?
【问题讨论】: