[Zope] Re: How to get the path?

Josef Meile jmeile@hotmail.com
Mon, 10 Mar 2003 20:58:50 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_0010_01C2E747.D9D3B5E0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

--- In zope@yahoogroups.com, Sorin Marti <mas@s...> wrote:
> Hi all,
>=20
> I want to upload files to the filesystem on my server (not into zope's =

> Data.fs)
>=20
> With <input type=3D"file" name=3D"file"> I get the filename...right?
>=20
> But If I want to copy it with an external method like this:
>=20
> copy =3D os.system('cp %s /tmp' %file.filename)
>=20
> it doesent work because file.filename is only the file but not the=20
> path... (for example test.pdf)
>=20
> How do I get the path?
I think you're asking the wrong question. I suppose what you
want to know is how to get the file content. You have to do
something like this:

fileContent=3Dcontext.REQUEST.form['file'].read()

Then, you have to take a look at the localfs dtml methods to
see how a file is created in the local file system.

Regards,
Josef
------=_NextPart_000_0010_01C2E747.D9D3B5E0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1141" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>--- In <A=20
href=3D"mailto:zope@yahoogroups.com">zope@yahoogroups.com</A>, Sorin =
Marti &lt;<A=20
href=3D"mailto:mas@s">mas@s</A>...&gt; wrote:<BR>&gt; Hi all,<BR>&gt; =
<BR>&gt; I=20
want to upload files to the filesystem on my server (not into zope's =
<BR>&gt;=20
Data.fs)<BR>&gt; <BR>&gt; With &lt;input type=3D"file" name=3D"file"&gt; =
I get the=20
filename...right?<BR>&gt; <BR>&gt; But If I want to copy it with an =
external=20
method like this:<BR>&gt; <BR>&gt; copy =3D os.system('cp %s /tmp'=20
%file.filename)<BR>&gt; <BR>&gt; it doesent work because file.filename =
is only=20
the file but not the <BR>&gt; path... (for example test.pdf)<BR>&gt; =
<BR>&gt;=20
How do I get the path?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I think you're asking the wrong =
question. I suppose=20
what you</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>want to know is how to </FONT><FONT =
face=3DArial=20
size=3D2>get the file content. You have to do</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>something like this:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
size=3D2>fileContent=3Dcontext.REQUEST.form['file'].read()<BR></FONT></DI=
V>
<DIV><FONT face=3DArial size=3D2>Then,&nbsp;you have to take a look at=20
the&nbsp;localfs&nbsp;dtml </FONT><FONT face=3DArial=20
size=3D2>methods&nbsp;to</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>see </FONT><FONT face=3DArial =
size=3D2>how a file is=20
created in the&nbsp;local file system.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Josef</FONT></DIV></BODY></HTML>

------=_NextPart_000_0010_01C2E747.D9D3B5E0--