Hi First of all i would like to thank you for giving me some idea..<br>As Jorgen told i did in same way<br>Hi Jorgen<br>I created a python script in zope instance to upload multiple files and its working successfully..<br>
but its storing the file inside custom folder as we know context always refer to current location i mean our-instance/custom but when i am giving container[&#39;bin&#39;] its giving me &#39;bin&#39; key error. i want to save that file inside my instance for example<br>
<br>myzope-instance/mydir/<b>&lt;uploaded file&gt;</b> is any one have any idea<br><br><b>REQUEST=context.REQUEST<br>sentFiles = {}<br>for key in context.REQUEST.keys():&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # getting all the ids<br>&nbsp;&nbsp;&nbsp; if key[:5]==&#39;file.&#39; and key[-3:]==&#39;.id&#39;:&nbsp;&nbsp; # we finding id <a href="http://file.XXX.id">file.XXX.id</a><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sentFiles[REQUEST[key]]=&#39;&#39;<br><br>for key in context.REQUEST.keys():<br>&nbsp;&nbsp;&nbsp; if key[:5]==&#39;file.&#39; and key[-3:]!=&#39;.id&#39;:&nbsp;&nbsp;&nbsp; #we&#39;ve got a file<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #found its id and make sure file exists<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if sentFiles.has_key(REQUEST[key+&#39;.id&#39;]) and REQUEST[key].filename:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sentFiles[REQUEST[key+&#39;.id&#39;]]=REQUEST[key]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; del sentFiles[REQUEST[key+&#39;.id&#39;]]&nbsp;&nbsp;&nbsp; #remove keys that dont have files<br>
<br>for k in sentFiles.keys():<br>&nbsp;&nbsp;&nbsp; </b><b style="color: rgb(0, 102, 0);">context.manage_addFile(k,sentFiles[k])</b><br><b>&nbsp;&nbsp;&nbsp; <span style="color: rgb(0, 0, 153);">container[&#39;bin&#39;]</span>.mydir.manage_addFile(k,sentFiles[k])<br>
<br>return str(len(sentFiles)) + &#39; files has been uploaded successfully&#39;</b><br><br><br><div class="gmail_quote">On Thu, Nov 6, 2008 at 7:49 PM, Jørgen Jørgensen <span dir="ltr">&lt;<a href="mailto:gardsted@yahoo.com">gardsted@yahoo.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


  
  

<div bgcolor="#ffffff" text="#000000">
Hello Praween Kumar - <br>
I would make a pythonscript on the zope like
&#39;locahost:8080/starinstance/myscript&#39;, taking 3 parameters, id, title
and file.<br>
remember to give it manager proxy rights (proxy in top of python script
edit screen, chose manager)<br>
script should be something like:<br>
&quot;&quot;&quot;<br>
container[&#39;bin&#39;].manage_addFile(id=id, title=title, file=file)<br>
&quot;&quot;&quot;<br>
I havent tested, sorry;-), but at least the direction should be
something like this.<br>
then change addfileurl to:<br>
<br>
<b>addfileurl=&#39;<a href="http://localhost:8080/starinstance/bin/manage_addFile" target="_blank">http://localhost:8080/starinstance/myscript</a>&#39;</b><br>
<br>
kind regards jorgen / denmark<br>
<br>
<br>
Praveen Kumar wrote:
<blockquote type="cite">Dear all,<div class="Ih2E3d"><br>
I want to save the file on filebased system. i am using urllib<br>
  <br></div><div><div></div><div class="Wj3C7c">
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" target="_blank">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></div></div><div class="Ih2E3d">
ImportError: /usr/lib/python2.4/lib-dynload/math.so: undefined symbol:
PyFPE_jbuf<br>
  <br></div><div><div></div><div class="Wj3C7c">
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" target="_blank">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" target="_blank">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" target="_blank">http://www.mahiti.org</a><br>
  <br>
  </div></div><pre><hr size="4" width="90%"><div class="Ih2E3d">
_______________________________________________
BangPypers mailing list
<a href="mailto:BangPypers@python.org" target="_blank">BangPypers@python.org</a>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a>
  </div></pre>
</blockquote>
</div>
<p> 

      </p><br>_______________________________________________<br>
BangPypers mailing list<br>
<a href="mailto:BangPypers@python.org">BangPypers@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/bangpypers" target="_blank">http://mail.python.org/mailman/listinfo/bangpypers</a><br>
<br></blockquote></div><br><br clear="all"><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>