前景提要
用下面的代码做文件上传,在自己电脑测试能够成功上传,到局域网其他电脑测试,显示 finished!了,但是没看到文件,请问前辈,是什么原因呢?该代码运行在 xp 系统上,上传文件夹已设置最高权限。import tornado.ioloop import tornado.web import shutil import os class UploadFileHandler(tornado.web.RequestHandler): def get(self): self.write(''' <html> <head><title>Upload File</title></head> <body> <form action='file' enctype="multipart/form-data" method='post'> <input type='file' name='file'/><br/> <input type='submit' value='submit'/> </form> </body> </html> ''') def post(self): upload_path=os.path.join(os.path.dirname(__file__),'files') #文件的暂存路径 file_metas=self.request.files['file'] #提取表单中‘ name ’为‘ file ’的文件元数据 for meta in file_metas: filename=meta['filename'] filepath=os.path.join(upload_path,filename) with open(filepath,'wb') as up: #有些文件需要已二进制的形式存储,实际中可以更改 up.write(meta['body']) self.write('finished!') app=tornado.web.Application([ (r'/file',UploadFileHandler), ]) if __name__ == '__main__': app.listen(3000) tornado.ioloop.IOLoop.instance().start()