Ok, there WAS a problem with this script, but thanks to various people (you know who you are) it now works. Im sure there are scurity issues and all that but it works:) The only one problem i still have is that i get an internal server error when the file size is too big. Must I do some code checking the MAX FILE size or is that what the $CGI: : POST_MAX line is suppose to do for me? Heres the form......
<FORM ENCTYPE="multipart/form-data" ACTION="the.cgi" METHOD=POST> Var1 : <input type=text name=var1><br> File : <INPUT NAME="file" TYPE="file"><p> <INPUT TYPE="submit" VALUE="Send File"> </FORM>
and heres the script.........
#!/usr/bin/perl use CGI; #SET SOME DEFAULT STUFF ################################################### use constant BUFFER_SIZE => 16_384; use constant MAX_FILE_SIZE => 48_576; $CGI::DISABLE_UPLOADS = 0; $CGI::POST_MAX = MAX_FILE_SIZE; #GET THE VARIABLE AND FILE INFORMATION ################################################### my $query = new CGI; my $filehandle = $query->upload('file'); my $filename = $query->param('file'); my $var1 = $query->param('var1'); #GET FILE NAME BY REMOVING FULL DIRECTORY INFO #eg C:\windows\blah\file.txt ############################################## @pathz = (split(/\\/,$filename)); $fileb = $pathz[$#pathz]; @pathza = (split('/',$fileb)); $filename = $pathza[$#pathza]; #UPLOAD THE FILE TO SELECTED DESTINATION ############################################## open OUTPUT, ">/absolute/path/to/$filename" or die "Can't open: $!"; while (<$filehandle>) { print OUTPUT; } close OUTPUT or die "Can't close: $!"; #DONE ############################################## print "Content-type: text/html\n\n"; print "Sorted!<p>\n"; print "Passed Variable = $var1<p>"; print "File name uploaded was <i>$filename</i><p>\n"; exit;
Thankyou everyone!, I hope that helps alot of other people too!

In reply to File Upload - Complete Code by Thathom
in thread File Upload - What Next? by Thathom

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.