Your problem is probably an old version of CGI.pm which has a broken upload() method - some of them did from memory, that's part of the reason I wrote CGI::Simple. Anyway this can't be a cut and paste of your actual code as you show an error near ""binmode but you don't go no binmode in your posted code dude. The undefined filehandle can only be $fh. Change your code to this:

$fh = $q->upload('file') or die_nice(); sub die_nice { print $q->header; print "<p>Failed again, lets look at our CGI.pm version: ", $CGI:: +VERSION print "<p>Now here is our CGI object"; use Data::Dumper; print '<pre>', $q->escapeHTML(Dumper $q), '</pre>'; exit; }

I suspect that your HTML form does not specify either multipart/form-data or POST. Show us how you call the script from the HTML please. It MUST look pretty much like this or it is never going to work:

<form method="post" action="http://mysite.com/cgi-bin/upload.cgi" enct +ype="multipart/form-data"> <p>Upload File <input type="file" name="file"> <br> <input type="submit" name="submit" value="Upload"> </form>

Other points are that you get the constants from Fcntl but don't use them (probably won't work on Windows anyway). Your filename validation is also pretty pointless

Did you follow my suggestions here?

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: file upload (again) by tachyon
in thread file upload (again) by r_mehmed

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.