Hi again. Perl newbie struggling to learn more Wisdom... Urrg. I'm probably missing something very basic, that I can't see. . . Here's what's happening:

I'm using a form that allows a user to browse to a file on their local system and upload it to our webserver. When I tested it on my local server it works fine.

However, when I test it on our actual web server, the Open function that reads the file (just prior to uploading it) seems to be looking for the file on the server, instead of on the local system, because it always dies saying it can't find the file.

I need it to read the specified user's local file as specified in the form's <input type="file"> tag. It dies in this line:

open (IN,$fullpath) || dienice("Couldn't open file ** $fullpath ** f +or reading: $!");
What am I missing? Here's my upload code snippet:
$uploadpath = "newsletters/"; # Fullpath comes from file specified in the form $file = $fullpath; $file=~s/^.*(\\|\/)//; # STRIP PATHWAY OFF! # binmode $fullfile; $file = lc($file); #print "<p>Testing...file is: $file"; $buffer = ''; #print "<p>Testing...uploadpath is: $uploadpath"; #print "<p>Testing...Filehandle is: $uploadpath" . "$file"; # Open the file for reading open (IN,$fullpath) || dienice("Couldn't open file ** $fullpath ** f +or reading: $!"); # Open the directory for writing to open (SAVEFILE, ">$uploadpath"."$file") || dienice("Can't open fileh +andle: $uploadpath" . "$file $!\n"); binmode SAVEFILE; $i=0; while ($bytes = read(IN, $buffer, 1024)) { $bytesread += $bytes; print SAVEFILE $buffer; } close(SAVEFILE) || dienice ("Can't close filehandle: $uploadpath/$fi +le $!\n"); close (IN);

In reply to Open(IN,$fullpath) can't find local file by JaredHess

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.