2
피라미드를 실행하는 서버에 파일 (이미지)을 업로드하는 시스템을 구현하려고합니다. 지금,이 코드는 나에게 AttributeError: 'unicode' object has no attribute 'file'
예외를 제공합니다피라미드 - 이미지 업로드 및 디스크에 저장
서버 측 :
session = Session()
username = authenticated_userid(request)
if username == None:
return HTTPNotFound()
else:
user = session.query(User).filter(User.username == username).first()
if 'photo.submitted' in request.params:
input_file = request.POST['file_input'].file
tmp = '../static/images/%s' % (session.query(ProfilePic).order_by(-ProfilePic.photo_id).first().photo_id + 1)
open(tmp, 'w').write(input_file.read())
tmp.close()
return Response('OK')
return {}
HTML : 간단한 것 같지만 작동하지 않습니다
<html>
<body>
<form action="/settings" method="post">
<input type="file" name="file_input" value="Choose image" />
<p><input type="submit" name="photo.submitted" value="Save" /></p>
</form>
</body>
</html>
뭔가. this 튜토리얼을 따르려고했지만 비디오/오디오 파일에서만 작동합니다. 이 작품을 어떻게 만들 수 있습니까? 파일 업로드에 대한
을 오 와우. 나는 너무 어리 석다. 내 얼굴 앞에서 바로 그랬다. – Wiz