Web Servers General Talk - Apache upload with INPUT type=file broken?

This is Interesting: Free IT Magazines  
Home > Archive > Web Servers General Talk > January 2004 > Apache upload with INPUT type=file broken?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Apache upload with INPUT type=file broken?
Will Stuyvesant

2004-01-19, 6:32 am

{copy from posting at comp.lang.python)

The problem I described in this thread is with Apache, not with
Python! And the unix Apache at my work has no problems, its only the
Windows Apache versions. So the Apache peeps will probably say it's a
*Windows* problem 0-)

I found out with the following: I can now avoid the first HTML page
with the .zip upload, instead I upload the .zip to my Python CGI
program with this little program:


import urllib
import webbrowser

webserviceURI = r'http://localhost/cgi-bin/mycgiprogram.py'
startpageName = 'start.xml'


# instead of a HTML page with INPUT type=file just read the file
fp = open(fname, 'rb')
data = fp.read()
fp.close()

# all CGI parameters in a dict, and encoded
params = urllib.urlencode({ 'yourfile': data })

# call the CGI program and read what it returns
f = urllib.urlopen(webserviceURI, params)
webpage = f.read()

# save it locally in a file
wpfp = open(startpageName, 'w')
wpfp.write(webpage)
wpfp.close()

# show it in your browser
webbrowser.open(startpageName)


--
If pro is the opposite of con, what is the opposite of progress?
w_ashley

2004-01-19, 6:32 am

hwlgw@hotmail.com (Will Stuyvesant) wrote in message news:<cb035744.0312070150.4a7c1935@posting.google.com>...
quote:

> {copy from posting at comp.lang.python)
>
> The problem I described in this thread is with Apache, not with
> Python! And the unix Apache at my work has no problems, its only the
> Windows Apache versions. So the Apache peeps will probably say it's a
> *Windows* problem 0-)
>
> I found out with the following: I can now avoid the first HTML page
> with the .zip upload, instead I upload the .zip to my Python CGI
> program with this little program:
>
>
> import urllib
> import webbrowser
>
> webserviceURI = r'http://localhost/cgi-bin/mycgiprogram.py'
> startpageName = 'start.xml'
>
>
> # instead of a HTML page with INPUT type=file just read the file
> fp = open(fname, 'rb')
> data = fp.read()
> fp.close()
>
> # all CGI parameters in a dict, and encoded
> params = urllib.urlencode({ 'yourfile': data })
>
> # call the CGI program and read what it returns
> f = urllib.urlopen(webserviceURI, params)
> webpage = f.read()
>
> # save it locally in a file
> wpfp = open(startpageName, 'w')
> wpfp.write(webpage)
> wpfp.close()
>
> # show it in your browser
> webbrowser.open(startpageName)



uhm what was the the problem? looks like a neat trick to me
w_ashley

2004-01-19, 6:32 am

unless of course it doesn't work on the windows box but does at home
could it
be the version of Python or OS.... since Python my natively compile or
run scripts where as windows???????? dunno it would seem the sollution
is to make sure your libraries are identical perhaps either that or
using linux instead or why use apache on windows why not IIS?
really though I'm not sure have you had any other issues using python
code from your work at home?
w_ashley

2004-01-19, 6:32 am

note somehow the word work turned into home in the first instance or
so .. anyway it may just be os compatibility with the packages
python and apache not sure though however there seems to be other
instances of errors caused by os incompatibility... the only other
thing I can think of is the libraries..
Will Stuyvesant

2004-01-19, 6:32 am

I should have replied earlier to my own post perhaps:

The problem only occured under Windows.

The problem is solved by using

python -u

in the #!, under windows as

#!c:\python23\python.exe -u

as the first line in the CGI script, for unbuffered binary stdout and such.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com