Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

How do I delete temporary upload files?

by PriNet (Monk)
on Oct 18, 2003 at 22:53 UTC ( [id://300338]=perlquestion: print w/replies, xml ) Need Help??

PriNet has asked for the wisdom of the Perl Monks concerning the following question:

when i upload a file/picture from a client to the server, it creates a temp file (e.g. CGItemp2345)... what variable contains this temp filename so i can delete it when the upload/transfer is complete?


you mean there's any easier way?
  • Comment on How do I delete temporary upload files?

Replies are listed 'Best First'.
Re: How do I delete temporary upload files?
by hossman (Prior) on Oct 19, 2003 at 07:45 UTC
    Assuming you're using CGI, it (should) delete the temp file for you when it's done with it. (search for the documantation of the "-private_tempfiles" option to see the details on controlling exactly when the "unlink" happens).
Re: How do I delete temporary upload files?
by barbie (Deacon) on Oct 19, 2003 at 10:54 UTC
    This is something I've noticed on occasions when using IIS on Windows. However, the files are created in a temporary folder that gets automatically cleaned periodically, so I don't worry about it. However, it has crossed my mind to figure out was causing it, but seeing as it seemed to happened only when using IIS, I'd just assumed that M$ had not implemented a clean up. If you're using another web server/OS, I'd be interested to know.

    --
    Barbie | Birmingham Perl Mongers | http://birmingham.pm.org/

      A general thing with files under Windows is, that they can't be deleted as long as they are open. So it might be useful to close the filehandles to the temporary files before trying to delete them. I don't know whether this applies here though.

      perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
        i wrote the script... apache web server, files are being created in the windows(98) directory that the script resides in... heres part of the code...
        if ($Data[3] eq "recieve") { $Data[11] = $fHandle->upload($Label[11]); $Data[12] = $fHandle->upload($Label[12]); if ((length($Data[11]) > 4)&&(lc(substr($Data[11],length($Data[11]) + - 4)) eq "\.jpg")) { open (FULLSIZE, ">".$Root."/records/classifieds/fullsize/".$Data +[2]."/".$Data[10]."\.jpg"); binmode(FULLSIZE); while (read($Data[11], $fBuffer, 1024)) {print FULLSIZE $fBuffer +} close (FULLSIZE); if ((length($Data[12]) > 4)&&(lc(substr($Data[12],length($Data[1 +2]) - 4)) eq "\.jpg")) { open (THUMBNAIL, ">".$Root."/records/classifieds/thumbnail/". +$Data[2]."/".$Data[10]."\.jpg"); binmode(THUMBNAIL); while (read($Data[12], $fBuffer, 1024)) {print THUMBNAIL $fBu +ffer} close (THUMBNAIL); goto RecieveDone; } copy($Root."/records/classifieds/fullsize/".$Data[2]."/".$Data[1 +0]."\.jpg", $Root."/records/classifieds/thumbnail/".$Data[2]."/".$Dat +a[10]."\.jpg"); } RecieveDone: $Data[11] = $Data[12] = ""; @Data = sub::clearcarry(0,@Data); @Data = sub::pushcommand("preview",@Data); goto AllDone; }


        you mean there's any easier way?
Re: How do I delete temporary upload files?
by thraxil (Prior) on Oct 19, 2003 at 00:41 UTC

    you're going to have to give us a little more to go on. i'm guessing that you're using some kind of canned script that someone else wrote. in that case, you'll have to let us know what that script is.

    or, you could just look through the script yourself and see where the file is written. search for 'open'.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://300338]
Approved by dirthurts
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 17:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found