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=&#39;admin&#39;<br>password=&#39;admin1&#39;<br>addfileurl=&#39;<a href="http://localhost:8080/starinstance/bin/manage_addFile">http://localhost:8080/starinstance/bin/manage_addFile</a>&#39;<br>
useragent=&quot;upload.py/0.1&quot;<br>filename=&#39;/home/praveen/Desktop/text.jpeg&#39;<br>filetitle=&#39;a nice test picture&#39;<br><br>class <span style="color: rgb(0, 102, 0);">MyUrlOpener</span>(<span style="color: rgb(0, 0, 153);">urllib.FancyURLopener</span>):<br>
 &nbsp; &nbsp;def prompt_user_passwd(self, host, realm):<br> &nbsp; &nbsp; &nbsp; &nbsp; return (user,password)<br> &nbsp; &nbsp;def __init__(self, *args):<br> &nbsp; &nbsp; &nbsp; self.version = useragent<br> &nbsp; &nbsp; &nbsp; <span style="color: rgb(0, 102, 0);">urllib.FancyURLopener.__init__(self, *args)</span><br>
<br>def main():<br> &nbsp; &nbsp; &nbsp; &nbsp;# use authentication and set the user agent<br> &nbsp; &nbsp; &nbsp; &nbsp;urllib._urlopener = MyUrlOpener()<br><br> &nbsp; &nbsp; &nbsp; &nbsp;# read the contents of filename into filebody<br> &nbsp; &nbsp; &nbsp; &nbsp;f=open(filename)<br> &nbsp; &nbsp; &nbsp; &nbsp;filebody=f.read()<br>
 &nbsp; &nbsp; &nbsp; &nbsp;f.close<br><br> &nbsp; &nbsp; &nbsp; &nbsp;# urlencode the id, title and file<br> &nbsp; &nbsp; &nbsp; &nbsp;params = urllib.urlencode({&#39;id&#39;: filename,<br> &nbsp; &nbsp; &nbsp; &nbsp;&#39;title&#39;:filetitle,<br> &nbsp; &nbsp; &nbsp; &nbsp;&#39;file&#39;:filebody})<br><br> &nbsp; &nbsp; &nbsp; &nbsp;# send the file to zope<br>
 &nbsp; &nbsp; &nbsp; &nbsp;f=urllib.urlopen(addfileurl, params)<br><br>if __name__ == &#39;__main__&#39;:<br> &nbsp; &nbsp;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>
&nbsp; File &quot;demo.py&quot;, line 36, in ?<br>&nbsp;&nbsp;&nbsp; main()<br>&nbsp; File &quot;demo.py&quot;, line 33, in main<br>&nbsp;&nbsp;&nbsp; f=urllib.urlopen(addfileurl, params)<br>&nbsp; File &quot;/usr/lib/python2.4/urllib.py&quot;, line 84, in urlopen<br>
&nbsp;&nbsp;&nbsp; return opener.open(url, data)<br>&nbsp; File &quot;/usr/lib/python2.4/urllib.py&quot;, line 192, in open<br>&nbsp;&nbsp;&nbsp; return getattr(self, name)(url, data)<br>&nbsp; File &quot;/usr/lib/python2.4/urllib.py&quot;, line 272, in open_http<br>
&nbsp;&nbsp;&nbsp; import httplib<br>&nbsp; File &quot;/usr/lib/python2.4/httplib.py&quot;, line 70, in ?<br>&nbsp;&nbsp;&nbsp; import mimetools<br>&nbsp; File &quot;/usr/lib/python2.4/mimetools.py&quot;, line 6, in ?<br>&nbsp;&nbsp;&nbsp; import tempfile<br>&nbsp; File &quot;/usr/lib/python2.4/tempfile.py&quot;, line 33, in ?<br>
&nbsp;&nbsp;&nbsp; from random import Random as _Random<br>&nbsp; File &quot;/usr/lib/python2.4/random.py&quot;, line 43, in ?<br>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp; &lt;form name=&quot;demo&quot; method=&quot;post&quot; ENCTYPE=&quot;multipart/form-data&quot; ACTION=&quot;&quot;&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;fieldset style=&quot;width:20%&quot;&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Id:&lt;input type=&quot;text&quot; name=&quot;title&quot; id=&quot;title&quot;/&gt;&lt;br&gt;&lt;br&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name:&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot;/&gt;&lt;br&gt;&lt;br&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Keywords:&lt;input type=&quot;text&quot; name=&quot;keywords&quot; id=&quot;keywords&quot;/&gt;&lt;br&gt;&lt;br&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;file&quot; name=&quot;upload&quot; id=&quot;upload&quot;/&gt;&lt;br&gt;&lt;br&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Save&quot; id=&quot;submit&quot;/&gt;&lt;br&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/fieldset&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp; &lt;/form&gt;<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: &nbsp;+91 9343297314<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; +91 9739854134<br><a href="http://www.mahiti.org">http://www.mahiti.org</a><br><br>