G'Day Monks

I'm having a bit of trouble with a CGI script I'm working on. I want my users to be able to upload a file to a certain directory. I have printed up an HTML form in which they specify the full path and name of the file they wish to upload. Here's the code:
print $cgi->header; print $cgi->start_html(-title=>'Upload New File'); print <<EOP; <p align=center><h2>Use the form below to upload a new file</h2></ +p> <hr> <form enctype="multipart/form-data" method=post> <p align=center><input type=file name="file" size=50></p> <p align=center><input type=submit value=Upload></p> EOP
The script is mainly targeted at Windows users, so the sort of paths I'm getting are similar to C:\Documents and Settings\Administrator\My Documents\somedocument.doc. The trouble is, after they click the submit button, the path I'm getting is only whatever is after the last backslash in the path. In the example I just gave, the 'file' parameter I get is somedocument.doc.

I know I could solve this problem by having the user enclose the path in quote marks, but I'd rather not have to have them do that. Any suggestions? Is there a way to automatically enclose the filename they enter in quotes? Or some way to ensure I get the full path?

Thanks for the help! I appreciate it.

In reply to File Upload Problem by Anonymous Monk

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.