Re: Newbie Question: How to upload an image file and show it?
Adam Woakes <[email protected]> Wed, 5 Jul 2017 05:47:00 -0700 (PDT)
| Newsgroups | gmane.comp.python.cherrypy |
|---|---|
| Message-ID | <[email protected]> |
thanks i was stuck on the same thing <a href='http://www.techsiast.com/'>oneplus 5</a> On Friday, August 11, 2006 at 2:41:48 PM UTC+5:30, ye wrote: > > I want to let the user upload an image file ,then display the image to > user. > How can I do it? > > I know how to upload file by reading the code in the tutorial09_file.py > ==================================================== > class FileDemo(object): > > def index(self): > return """ > <html><body> > <form action="upload" method="post" > enctype="multipart/form-data"> > filename: <input type="file" name="myFile" /><br /> > <input type="submit" /> > </form> > <a href="download"> downlaod </a> > </body></html> > """ > index.exposed = True > > def upload(self, myFile): > out = """<html> > <body> > myFile length: %s<br /> > myFile filename: %s<br /> > myFile mime-type: %s <br /> > </body> > </html>""" > > size = 0 > while True: > data = myFile.file.read(8192) > if not data: > break > size += len(data) > return out % (size, myFile.filename, myFile.type) > upload.exposed = True > > ============================================== > And what should I do next to show the image ? > > Is there any example about this? > > -- You received this message because you are subscribed to the Google Groups "cherrypy-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected] Visit this group at https://groups.google.com/group/cherrypy-users. For more options, visit https://groups.google.com/d/optout.