Do you already have some kind of sessioning set up?
If you have:
Write the PID ($$) of the script processing the upload to the session
Point your Cancel-button to another CGI script which reads the PID of the upload-script from the session and kill's itkill 15,$Upload_PID; # Hard-kill and risk half-uploaded temp-files on
+disk, if you write them
kill 10,$Upload_PID; # Send SIGUSR1 to the upload-script
When using SIGUSR1 (second line above), you could clean up before aborting the upload script, for example:$SIG{USR1} = sub { unlink $Temp_File; exit; };
If you don't have any sessioning, add a hidden field with some unique token to the upload form. A lovely thing could be:
my $Token = unpack('H*',pack('L',time).pack('S',$$));
Your upload script makes itself findable using the token it received from the form (a good idea would be adding the token as GET parameter for early parsing), for example:
$0 .= '('.$Token.')';
or
open my $ID_File,'>/dev/shm/tokenfiles/'.$Token;
print $ID_File $$;
close $ID_File;
(You should verify the incoming token for matching /^
\da-f$/ for security reasons for both solutions! Don't forget to clean up the file after the upload has finished when using a ID-file.)
Feed the same token from the form to your cancel-script and let it find the PID of the upload process by searching the process table or looking at /dev/shm/tokenfiles/$Token. The rest is the same as above: Now as you know the PID, you could send a cancel signal to the process.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.