Professional Web Applications Themes

CGI.pm / Upload File / delete temporary file (CGITemp****) - PERL Beginners

Hi All, Been ages since I last posted to this list... Anyhoo, I have a script which handles the uploading of a file. It uses the CGI module to get the form params etc and open/read/close statements to receive the file. This is fine and all works well. The problem is a temporary file (of the same size as the uploaded file) is created in the TEMP directory. It has a name along the lines of 'CGITemp****' where the asterisks represent a sequence number. Is there any switch/arg to prevent this or at least delete this file when the upload ...

  1. #1

    Default CGI.pm / Upload File / delete temporary file (CGITemp****)

    Hi All,

    Been ages since I last posted to this list...

    Anyhoo, I have a script which handles the uploading of a file.

    It uses the CGI module to get the form params etc and open/read/close
    statements to receive the file. This is fine and all works well. The
    problem is a temporary file (of the same size as the uploaded file) is
    created in the TEMP directory. It has a name along the lines of
    'CGITemp****' where the asterisks represent a sequence number.

    Is there any switch/arg to prevent this or at least delete this file when
    the upload is completed? I have googled to no avail.

    I suppose I could just delete it myself but I don't know the CGITemp
    sequence number.

    If no one knows I guess i'll have to have a look at the code for CGI.pm :(

    I'm on Win32, perl v5.6.1, CGI v2.752

    Thanks

    Toby
    Toby Guest

  2. #2

    Default CGI.pm / Upload File / delete temporary file (CGITemp****)




    You don't have to bother about deleting it. GCI.pm takes care of that.

    HTH



    ||
    ||Hi All,
    ||
    ||Been ages since I last posted to this list...
    ||
    ||Anyhoo, I have a script which handles the uploading of a file.
    ||
    ||It uses the CGI module to get the form params etc and open/read/close
    ||statements to receive the file. This is fine and all works well. The
    ||problem is a temporary file (of the same size as the uploaded file) is
    ||created in the TEMP directory. It has a name along the lines of
    ||'CGITemp****' where the asterisks represent a sequence number.
    ||
    ||Is there any switch/arg to prevent this or at least delete this file
    when
    ||the upload is completed? I have googled to no avail.
    ||
    ||I suppose I could just delete it myself but I don't know the CGITemp
    ||sequence number.
    ||
    ||If no one knows I guess i'll have to have a look at the code for
    CGI.pm :(
    ||
    ||I'm on Win32, perl v5.6.1, CGI v2.752
    ||
    ||Thanks
    ||
    ||Toby
    ||
    ||--
    ||To unsubscribe, e-mail: org
    ||For additional commands, e-mail: org
    ||<http://learn.perl.org/> <http://learn.perl.org/first-response>



    Babale Guest

  3. #3

    Default Re: CGI.pm / Upload File / delete temporary file (CGITemp****)

    I'm working on the same thing, and actually I was having trouble with
    the first step. What does your "open" call look like? Here's mine:

    $filename = $query->param('filex');
    open($filename,">z.jpg");
    binmode($filename);
    print $filename $in;
    close($filename);
    print "DONE, Uploaded Size: ".length($in)." bytes";

    This gives me a complete temp file and an empty "z.jpg".

    I know I'm calling something wrong; I think it's because $in isn't
    defined as anything... but I don't know what to define it as.
    <STDOUT>?

    Anyway, for your problem the CGI.pm doc says that you have to manually
    close the tempfile handle, or the attempt to delete it will fail. This
    is a Windows problem; it can't delete a file that is still open.

    They say to do this:

    $filename = $query->param('filex');
    $tmpfilename = $query->tempFileName($filename);

    and then i would suppose you just need to do a:

    close($tmpfilename);

    Let me know if that works out for you... I think I'll be needing it
    after I figure out the open(); part!

    -Kris

    com.au (Toby Stuart) wrote in message news:<figsyd>... 
    Kris Guest

  4. #4

    Default RE: CGI.pm / Upload File / delete temporary file (CGITemp****)


     

    I thought it would but it doesn't. Not on Win32 anyway. Is there some
    destructor that's supposed to be called? Maybe a $cgi->close or similar?

    BTW. I find it annoying that the CGI.pm doentation does not contain a
    simple list of properties and methods ... at least i can't find them ;)

    I did discover a setTempFile method which i believe will allow me to name
    the temp file thus allowing easy deletion.




    Toby

     
    Toby Guest

  5. #5

    Default Re: CGI.pm / Upload File / delete temporary file (CGITemp****)

    Read my earlier post! It's in there, I swear!

    com.au (Toby Stuart) wrote in message news:<figsyd>... 
    >
    > I thought it would but it doesn't. Not on Win32 anyway. Is there some
    > destructor that's supposed to be called? Maybe a $cgi->close or similar?
    >
    > BTW. I find it annoying that the CGI.pm doentation does not contain a
    > simple list of properties and methods ... at least i can't find them ;)
    >
    > I did discover a setTempFile method which i believe will allow me to name
    > the temp file thus allowing easy deletion.
    >
    >
    >
    >
    > Toby
    >

    > open/read/close 
    > well. The 
    > uploaded file) is 
    > when 
    > CGI.pm :( [/ref]
    Kris Guest

Similar Threads

  1. Replies: 2
    Last Post: October 14th, 07:02 PM
  2. cffile upload file field returns temporary path
    By Rustywater in forum Macromedia ColdFusion
    Replies: 2
    Last Post: February 25th, 08:27 PM
  3. CGItemp-file and windows
    By Arjen in forum PERL Miscellaneous
    Replies: 1
    Last Post: September 17th, 01:00 PM
  4. how to upload an image selected from html file to flash file?
    By apple pie webforumsuser@macromedia.com in forum Macromedia Dynamic HTML
    Replies: 0
    Last Post: July 5th, 12:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139