[Xitami] Folder permission issue or PERL error???

Admin (MRJ) xitami@lists.xitami.org
Fri, 14 Jan 2005 00:31:07 -0700


This is a multi-part message in MIME format.

------=_NextPart_000_00B3_01C4F9D0.5665EA50
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I should have added this too...

Error in the CGIErr.log of Xitami is noted as=20

print() on closed filehandle OUTFILE at D:\xit\cgi-bin\upload.cgi line =
62, <fh00001E%3A\testimage.jpg> line 23.

the line number refers to the 23'rd line in the image file.


  ----- Original Message -----=20
  From: Admin (MRJ)=20
  To: xitami@lists.xitami.org=20
  Sent: Friday, January 14, 2005 0:11
  Subject: [Xitami] Folder permission issue or PERL error???


  I am having a bit of trouble here.

  I have ActivePerl 5.8.6 installed
  Xitami 2.5c2 installed on Win 2k

  and I'm trying to get   http://www.radinks.com/upload/
  this little thing to work in the lite edition free version.

  Now everything is ok as long I try using the html-perl.htm file to do =
an upload but=20
  it fails stating there is a error on line 62 in the upload.cgi file.

  the following is the CGI file I am using.

  Any hints as to why it won't upload to my xitami box?
  I really don't know any Perl myself to debug this thing in a proper =
manner.

  Thanks for any help.

  =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D


  #!/usr/bin/perl -w

  #
  # Perl script to accept file uploads. This script is provided for =
demonstration=20
  # purposes only.
  # you need to have the CGI module installed.
  #
  # Copyright Rad Inks (pvt) 2003
  # http://www.radinks.com


  use CGI;  =20
  use Carp;

  sub bye_bye {
   $mes =3D shift;
   print "<br>$mes<br>\n";

   exit;
  }



  print "Content-type: text/html\n\n ";
  my $cg =3D new CGI();

  #
  # Files will not be saved if $save_path is left undefined. Please make =
sure
  # the path you choose is writable.
  #

  my $save_path =3D "D:\\tmpUL\\";

  print <<__TABLE__;
  <html>
  <body  bgcolor=3D"FFFFCC">

  <table border=3D"1" cellpadding=3D"5" width=3D"100%" align=3D"center">
  <tr><td colspan=3D"2" bgcolor=3D"#0066cc"><font color=3D"#FFFFCC" =
size=3D"+1" align=3D"center">Files Uploaded</font></td></tr>
  <tr  bgcolor=3D"#ffff00"><td style=3D"font-size: 110%;"><nobr>File =
Name</nobr></td>
   <td style=3D"font-size: 110%"  align=3D"right"><nobr>File =
size</nobr></td></tr>
  __TABLE__

  my $size =3D $cg->param;
  for($i=3D0 ; $i < $size ; $i++)
  {
   $file_upload  =3D $cg->param("userfile[$i]");

   if($file_upload) {
    my $fh =3D $cg->upload("userfile[$i]");
    my @name =3D split('/',$fh);
    my $filename =3D $name[$#name];
   =20
    $fsize =3D(-s $fh);
    print "<tr><td>$filename </td>\n";
    print "<td>$fsize</td></tr>";
   =20
    if(defined($save_path))
    {
     open (OUTFILE,">>$save_path/$filename");
     while(<$fh>) {
      print OUTFILE $_;                                                  =
                ### THIS IS WHERE THE ERROR OCCURS
     }
     close(OUTFILE);
    }
    else
    {
     carp 'not saving';
    }
   }
  }


  print <<__TABLE__;
  </table>

  <p style=3D"text-align:center; font-size: 80%">Sample  Perl Upload =
handler provided by
   <a href=3D"http://www.radinks.com/?dn">Rad Inks</a></p>
  =20
  <p style=3D"text-align:center; font-size: 80%">have you seen our <a =
href=3D"http://www.radinks.com/sftp/?dn">Secure FTP Applet</a> or our
  <a href=3D"http://www.radinks.com/mms/?dn">Multimedia Messaging =
Solution</a>?</p>

  __TABLE__


   
------=_NextPart_000_00B3_01C4F9D0.5665EA50
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.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I should have added this =
too...</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Error in the CGIErr.log of =
Xitami&nbsp;is noted as=20
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial color=3D#800000 size=3D2>print() on closed =
filehandle OUTFILE=20
at D:\xit\cgi-bin\upload.cgi line 62, &lt;fh00001E%3A\testimage.jpg&gt; =
line=20
23.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>the line number refers to the 23'rd =
line in the=20
image file.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dadmin@mrjdesign.com =
href=3D"mailto:admin@mrjdesign.com">Admin (MRJ)</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3Dxitami@lists.xitami.org=20
  href=3D"mailto:xitami@lists.xitami.org">xitami@lists.xitami.org</A> =
</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, January 14, 2005 =
0:11</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Xitami] Folder =
permission issue=20
  or PERL error???</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=3DArial size=3D2>I am having a bit of trouble =
here.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>I have ActivePerl 5.8.6 =
installed</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>Xitami 2.5c2 installed on Win =
2k</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>and I'm trying to get&nbsp;&nbsp; =
</FONT><A=20
  href=3D"http://www.radinks.com/upload/"><FONT face=3DArial=20
  size=3D2>http://www.radinks.com/upload/</FONT></A></DIV>
  <DIV><FONT face=3DArial size=3D2>this little thing to work in the lite =
edition=20
  free version.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Now everything is ok as long I try =
using the=20
  html-perl.htm file to do an upload but </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>it fails stating there is a error on =
line 62 in=20
  the upload.cgi file.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>the following is the CGI file I am=20
  using.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Any hints as to why it won't upload =
to my xitami=20
  box?</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>I really don't know any Perl myself =
to debug this=20
  thing in a proper manner.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Thanks for any help.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial =
size=3D2>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</FONT></DIV>=

  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>#!/usr/bin/perl -w</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>#<BR># Perl script to accept file =
uploads. This=20
  script is provided for demonstration <BR># purposes only.<BR># you =
need to=20
  have the CGI module installed.<BR>#<BR># Copyright Rad Inks (pvt) =
2003<BR># <A=20
  =
href=3D"http://www.radinks.com">http://www.radinks.com</A></FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV><FONT face=3DArial =
size=3D2>
  <DIV><BR>use CGI;&nbsp;&nbsp;&nbsp;<BR>use Carp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>sub bye_bye {<BR>&nbsp;$mes =3D shift;<BR>&nbsp;print=20
  "&lt;br&gt;$mes&lt;br&gt;\n";</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;exit;<BR>}</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>print "Content-type: text/html\n\n ";<BR>my $cg =3D new =
CGI();</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>#<BR># Files will not be saved if $save_path is left undefined. =
Please=20
  make sure<BR># the path you choose is writable.<BR>#</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>my $save_path =3D "D:\\tmpUL\\";</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>print &lt;&lt;__TABLE__;<BR>&lt;html&gt;<BR>&lt;body&nbsp;=20
  bgcolor=3D"FFFFCC"&gt;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&lt;table border=3D"1" cellpadding=3D"5" width=3D"100%"=20
  align=3D"center"&gt;<BR>&lt;tr&gt;&lt;td colspan=3D"2"=20
  bgcolor=3D"#0066cc"&gt;&lt;font color=3D"#FFFFCC" size=3D"+1"=20
  align=3D"center"&gt;Files=20
  Uploaded&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;<BR>&lt;tr&nbsp;=20
  bgcolor=3D"#ffff00"&gt;&lt;td style=3D"font-size: =
110%;"&gt;&lt;nobr&gt;File=20
  Name&lt;/nobr&gt;&lt;/td&gt;<BR>&nbsp;&lt;td style=3D"font-size: =
110%"&nbsp;=20
  align=3D"right"&gt;&lt;nobr&gt;File=20
  size&lt;/nobr&gt;&lt;/td&gt;&lt;/tr&gt;<BR>__TABLE__</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>my $size =3D $cg-&gt;param;<BR>for($i=3D0 ; $i &lt; $size ;=20
  $i++)<BR>{<BR>&nbsp;$file_upload &nbsp;=3D =
$cg-&gt;param("userfile[$i]");</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&nbsp;if($file_upload) {<BR>&nbsp;&nbsp;my $fh =3D=20
  $cg-&gt;upload("userfile[$i]");<BR>&nbsp;&nbsp;my @name =3D=20
  split('/',$fh);<BR>&nbsp;&nbsp;my $filename =3D=20
  $name[$#name];<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;$fsize =3D(-s=20
  $fh);<BR>&nbsp;&nbsp;print "&lt;tr&gt;&lt;td&gt;$filename=20
  &lt;/td&gt;\n";<BR>&nbsp;&nbsp;print=20
  =
"&lt;td&gt;$fsize&lt;/td&gt;&lt;/tr&gt;";<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;=
if(defined($save_path))<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;open=20
  =
(OUTFILE,"&gt;&gt;$save_path/$filename");<BR>&nbsp;&nbsp;&nbsp;while(&lt;=
$fh&gt;)=20
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;print OUTFILE=20
  =
$_;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
  <FONT color=3D#ff0000>### THIS IS WHERE THE ERROR=20
  =
OCCURS</FONT><BR>&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;close(OUTFILE);=
<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;else<BR>&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nb=
sp;carp=20
  'not saving';<BR>&nbsp;&nbsp;}<BR>&nbsp;}<BR>}</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><BR>print &lt;&lt;__TABLE__;<BR>&lt;/table&gt;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>&lt;p style=3D"text-align:center; font-size: 80%"&gt;Sample&nbsp; =
Perl=20
  Upload handler provided by<BR>&nbsp;&lt;a href=3D"<A=20
  =
href=3D'http://www.radinks.com/?dn">Rad'>http://www.radinks.com/sftp/?dn">Secure'>http://www.radinks.com/s=
ftp/?dn"&gt;Secure</A>=20
  FTP Applet&lt;/a&gt; or our<BR>&lt;a href=3D"<A=20
  =
href=3D'http://www.radinks.com/mms/?dn">Multimedia'>http://www.radinks.co=
m/mms/?dn"&gt;Multimedia</A>=20
  Messaging Solution&lt;/a&gt;?&lt;/p&gt;</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>__TABLE__</DIV>
  <DIV>&nbsp;</DIV>
  <DIV><BR></FONT>&nbsp;</DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_00B3_01C4F9D0.5665EA50--