You're missing a } at the end of sub bye_bye.

You have use CGI, but apparently are not using CGI, since the part at the beginning does all the input processing itself?

Use strict and use warnings should always be on. The following variables are global and should have their scope set:

$BASE_PATH, $LINE, $bRead, $buffer, $content_type, $delete_file, $dir_name, $file_name, $folder, $interval, $len, $max_upload, $mes, $name, $ofh, $pair, $post_prog, $sessionid, $size, $submit, $user_dir, $user_level, $value, %form, @pairs

And there are various warnings as well, that I'm not going to bother fixing. You ought to be able to.

It's best to never lock the file you're trying to process. Hash (or add some suffix to) the file path, then create and lock a file with that hash as the file name. Do your processing on the file. Unlock the hash. This allows you to, for instance, open a file for read, read the number, close it, open the file for write, write the updated number, close it - without losing your lock. I really don't like the way you seem to be doing it.

As for overwriting your directory, I still haven't figured out why that's happening, but you might try printing all the paths you open for write or read/write and see if any of them is the wrong path. If that doesn't identify the problem, about all I can suggest is sectioning your program into a number of smaller subs with clearly identified input, output, and processing objectives, and testing each one to make sure it does what it's supposed to.


In reply to Re: Large upload files causing parent directory to be deleted by TedPride
in thread Large upload files causing parent directory to be deleted by clem_c_rock

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.