I think the "How Not to Ask a Question" link is almost a little bit unsuitable in this case because the OP asked a clear question but seems to have been confused by online tutorials that cover PHP rather than Perl.

@Bruce32903, I think the error you got when using the example posted above is most likey due to copying the path given in the example, which will (most likely) not exist on your system. Just change '/usr/local/web/users/feedback' to something that does exist on your system and make sure that you end up with a unique filename. For example, if you can identify your user by a user ID then you might want to write the uploaded file to

'some/path/to/uploaded/files/USER_XXX/feedback'

You only need to understand how to read and write files to the disk. When asked to upload a file, your web server will save the file in a temporary location on your filesystem and all you get from CGI is either a handle on that file (this is the first example in the first reply to your post) or the full name to the temp file (second example).

Once you have that handle, you read from it like you would read from any other file on the disk in a "while (<FILEHANDLE>){..}" loop and you can either write to a new file or jsut do something with the informatin you got and let the system automatically dispose of the tmp file if you don't need to store it.

Just one more thing: if you happen to be on Windows, you might need to add a line

binmode OUTFILE;
after the "open" statement in the example in the first reply. As far as I know, it doesn't do any harm to put it in just in case anyway.


In reply to Re^4: File upload under Apache2 by tospo
in thread File upload under Apache2 by Bruce32903

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.