[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Fw: Problem with deleting uploaded files



Hi,

I'm forwarding a message from another news group which I think answers your
question.
I recommend that you join the mod_perl mailing list (www.apache.org).
This is really a fantastic source. In fact you even get to meet Randal
Scwartz and other perl gurus occasionally in this list !!

Murali
-----Original Message-----
From: Ken Y. Clark <kclark@xxxxxxxxxx>
To: modperl@xxxxxxxxxx <modperl@xxxxxxxxxx>
Date: 05 May 2000 10:54
Subject: Re: Problem with deleting uploaded files


>On Thu, 4 May 2000, Srinidhi Rao S wrote:
>
>> Hi all,
>>     Here I have a problem. I used CGI module to upload a file. But the
>> problem is that the temp file created by CGI module is not getting
>> deleted even after execution finished. It simply getting heaped in
>> temp directory eating memory. Can anyone please give me a way through
>> this???
>>     Here is a part of code I have written
>>
>> use CGI;
>> use CGI qw (:standard);
>> use CGI::Carp qw (fatalsToBrowser);
>>
>> $CGI::POST_MAX=1024 * 350;
>>  my $QObject = new CGI;
>>  print $QObject->header;
>>  $file_name = $QObject->param('upload');
>>
>>  open (FILE,">../xxx.jpeg") || die "cannot open the image file\n";
>>  while(read($file_name,$data,1024))
>>

>>   print FILE $data;
>>   }
>>  close(FILE);
>>  print "Success";
>>
>> I also have one more problem. If I upload a Image file, the image will
>> be corrupted in the uploaded file. Why is this hapenning?  Any help is
>> hugely appriciated.
>
>from `perldoc CGI`:
>
>STARTING AND ENDING A FORM
>       ....
>       multipart/form-data
>           This is the newer type of encoding introduced by
>           Netscape 2.0.  It is suitable for forms that contain
>           very large fields or that are intended for
>           transferring binary data.
>
>also:
>
>
>       To be safe, use the upload() function (new in version
>       2.47).  When called with the name of an upload field,
>       upload() returns a filehandle, or undef if the parameter
>       is not a valid filehandle.
>
>            $fh = $query->upload('uploaded_file');
>            while (<$fh>) {
>                  print;
>            }
>
>       This is the recommended idiom.
>
>there's some more info there.  do perldoc and then search for "binary."
>
>ky
>