Search the web
Sign In
New User? Sign Up
ClearSilver
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
sample file upload   Message List  
Reply | Forward Message #1200 of 1347 |
Re: sample file upload

Thanks for your response,
but i dont want to use python or any other script.
I can use clearsilver C API with cgi application .i just want to know
whether it is possible or not.If any one have a sample application
please upload

Regards
Max


--- In ClearSilver@yahoogroups.com, Brandon Long <blong@...> wrote:
>
> Do you have a perferred language?
>
> Attached is a test python one I had lying around. upload.py is a dirt
> simple one, upload2.py uses a callback so you get information as the
> uplaod is going on.
>
> Brandon
>
> On 08/08/08 maxsimon1980 uttered the following other thing:
> > hello every one,
> >
> > can anyone send me a sample code for file up load.
> > please send me the code for cgi and html part.
> >
> > Regards
> > Max
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> --
> "A fundamental law: no matter how good you are, someone somewhere
> believes that you're going to Hell." -- Andrew C. Bulhak
> http://www.fiction.net/blong/
>
> #!/usr/local/bin/python2.2
> import neo_cgi
> import sys, os
> import traceback
>
> def exceptionString():
> import StringIO
>
> ## get the traceback message
> sfp = StringIO.StringIO()
> traceback.print_exc(file=sfp)
> exception = sfp.getvalue()
> sfp.close()
>
> return exception
>
> class Page:
> def __init__(self):
> self.ncgi = neo_cgi.CGI()
> self.ncgi.setUploadCB(None, self.upload_cb)
> try:
> os.unlink('/tmp/cstest.txt')
> except os.error:
> pass
> try:
> os.unlink('/tmp/file')
> except os.error:
> pass
> self.ncgi.parse()
>
> def upload_cb(self, foo, nread, length):
> f = open('/tmp/cstest.txt', 'a')
> f.write("Uploaded %d out of %d\n" % (nread, length))
> f.close()
> return 0
>
> def display(self, file):
> if self.ncgi.hdf.getValue("Query.file", ""):
> try:
> fp = self.ncgi.filehandle("file")
> data = fp.read()
> f = open("/tmp/file", "w")
> f.write(data)
>
> except neo_cgi.CGIFinished:
> return
> except Exception, Reason:
> sys.stderr.write("Python Exception: %s\n" % (str(repr(Reason))))
> s = neo_cgi.text2html("Python Exception: %s" %
exceptionString())
> self.ncgi.error(s)
> self.ncgi.display(file)
> sys.stdout.write('<pre>%s</pre>' %
> neo_cgi.htmlEscape(self.ncgi.hdf.dump()))
>
> p = Page()
> p.display("hello.cst")
>
> <html>
> <title>Test upload</title>
> <body>
> <form name=upload method=POST enctype="multipart/form-data">
> <input type=file name=file>
> <input type=submit name=Action.Upload value="Upload">
> </body>
> </html>
>
> #!/usr/bin/env python
>
> import sys, os, traceback, string
> import neo_cgi
>
> def log (s):
> sys.stderr.write("CGI: %s\n" % s)
>
> def exceptionString():
> import StringIO
>
> ## get the traceback message
> sfp = StringIO.StringIO()
> traceback.print_exc(file=sfp)
> exception = sfp.getvalue()
> sfp.close()
>
> return exception
>
> def main (argv, environ):
> # log ("starting")
> cgi = neo_cgi.CGI("")
>
> try:
> fp = cgi.filehandle("file")
> print "Content-Type: text/plain\r\n\r\n"
> data = fp.read()
> print data
>
> f = open("/tmp/file", "w")
> f.write(data)
>
> except neo_cgi.CGIFinished:
> return
> except Exception, Reason:
> log ("Python Exception: %s" % (str(repr(Reason))))
> s = neo_cgi.text2html("Python Exception: %s" % exceptionString())
> cgi.error (s)
>
> if __name__ == "__main__":
> main (sys.argv, os.environ)
>





Mon Aug 11, 2008 9:56 am

maxsimon1980
Offline Offline
Send Email Send Email

Forward
Message #1200 of 1347 |
Expand Messages Author Sort by Date

hello every one, can anyone send me a sample code for file up load. please send me the code for cgi and html part. Regards Max...
maxsimon1980
Offline Send Email
Aug 8, 2008
10:27 pm

Do you have a perferred language? Attached is a test python one I had lying around. upload.py is a dirt simple one, upload2.py uses a callback so you get...
Brandon Long
blong42
Offline Send Email
Aug 8, 2008
10:32 pm

Thanks for your response, but i dont want to use python or any other script. I can use clearsilver C API with cgi application .i just want to know whether it...
maxsimon1980
Offline Send Email
Aug 11, 2008
7:26 pm

Yes, its possible. The code is obviously similar to the python from before. The key point is, your HTML code must have a FORM element which has the extra...
Brandon Long
blong42
Offline Send Email
Aug 11, 2008
9:57 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help