Dear all,<br>I want to save the file on filebased system. i am using urllib<br><br>here i tried with this code<br><br><b>import urllib<br><br># fill these in<br>user='admin'<br>password='admin1'<br>addfileurl='<a href="http://localhost:8080/starinstance/bin/manage_addFile">http://localhost:8080/starinstance/bin/manage_addFile</a>'<br>
useragent="upload.py/0.1"<br>filename='/home/praveen/Desktop/text.jpeg'<br>filetitle='a nice test picture'<br><br>class <span style="color: rgb(0, 102, 0);">MyUrlOpener</span>(<span style="color: rgb(0, 0, 153);">urllib.FancyURLopener</span>):<br>
def prompt_user_passwd(self, host, realm):<br> return (user,password)<br> def __init__(self, *args):<br> self.version = useragent<br> <span style="color: rgb(0, 102, 0);">urllib.FancyURLopener.__init__(self, *args)</span><br>
<br>def main():<br> # use authentication and set the user agent<br> urllib._urlopener = MyUrlOpener()<br><br> # read the contents of filename into filebody<br> f=open(filename)<br> filebody=f.read()<br>
f.close<br><br> # urlencode the id, title and file<br> params = urllib.urlencode({'id': filename,<br> 'title':filetitle,<br> 'file':filebody})<br><br> # send the file to zope<br>
f=urllib.urlopen(addfileurl, params)<br><br>if __name__ == '__main__':<br> main()</b><br><br>when i compile this file with simple python demo.py it gives me error<br>Traceback (most recent call last):<br>
File "demo.py", line 36, in ?<br> main()<br> File "demo.py", line 33, in main<br> f=urllib.urlopen(addfileurl, params)<br> File "/usr/lib/python2.4/urllib.py", line 84, in urlopen<br>
return opener.open(url, data)<br> File "/usr/lib/python2.4/urllib.py", line 192, in open<br> return getattr(self, name)(url, data)<br> File "/usr/lib/python2.4/urllib.py", line 272, in open_http<br>
import httplib<br> File "/usr/lib/python2.4/httplib.py", line 70, in ?<br> import mimetools<br> File "/usr/lib/python2.4/mimetools.py", line 6, in ?<br> import tempfile<br> File "/usr/lib/python2.4/tempfile.py", line 33, in ?<br>
from random import Random as _Random<br> File "/usr/lib/python2.4/random.py", line 43, in ?<br> from math import log as _log, exp as _exp, pi as _pi, e as _e<br>ImportError: /usr/lib/python2.4/lib-dynload/math.so: undefined symbol: PyFPE_jbuf<br>
<br>so i compiled with this command <b style="color: rgb(153, 0, 0);">python2.4 demo.py</b> it does not give any error<br>but it does not give me output to when i check my directory where i am trying to save my jpeg file <b><a href="http://localhost:8080/starinstance/bin/manage_addFile">http://localhost:8080/starinstance/bin/manage_addFile</a> </b>there i do not find that file it means it is not able to store that file.<br>
<br>i do not know what i am trying to do..could any one please give me idea how may i store the file on file system.<br>i created a html page<br> <form name="demo" method="post" ENCTYPE="multipart/form-data" ACTION=""><br>
<fieldset style="width:20%"><br><br> Id:<input type="text" name="title" id="title"/><br><br><br> Name:<input type="text" name="name" id="name"/><br><br><br>
Keywords:<input type="text" name="keywords" id="keywords"/><br><br><br> <input type="file" name="upload" id="upload"/><br><br><br>
<input type="submit" name="submit" value="Save" id="submit"/><br><br> </fieldset><br> </form><br>once if user select any file it should store to specific location <b><a href="http://localhost:8080/starinstance/bin/manage_addFile">http://localhost:8080/starinstance/bin/manage_addFile</a><br>
<br></b>Any suggestion will be appreciable<br><br>Thanks.<br>-- <br>Praveen Kumar<br>Software Engineer<br>Mahiti Infotech Pvt. Ltd.<br># 33-34, Hennur Cross<br>Hennur Main Road<br>Bangalore, India - 560043<br>Mobile: +91 9343297314<br>
+91 9739854134<br><a href="http://www.mahiti.org">http://www.mahiti.org</a><br><br>