I am running an Apache server on a networked machine and want to allow people browsing the intranet on that machine to copy files from their machines to a specified dir on the server machine.

I am using "multipart/form-data" encoding to get the filename and pass this to the routine. The only problem is that this returns a local path to the file on the user's machine and when they're looking at the intranet (which runs on HTTP://GIOTTO) in their browsers, this is not the path to the file relative to the CGI routine that is running the FILE::COPY. I have tried frigging it but no luck.

Also, FILE::COPY itself seems to return very little info. At the moment I am using the following code (where "recourse" is the dir I want the files to be uploaded to):

$filename = $formdata{file}; @parts = split (/\\/,$filename); $sourcefilename = @parts[$#parts]; $targetdir = "\\\\\Giotto\\recourse"; $targetfilename = "$targetdir\\$sourcefilename"; print "The target directory for this file is: $targetdir"; print "This makes the target path: $targetfilename"; use File::Copy; if (copy $filename, $targetfilename) { print "Copy complete..."; } else { print "Error"; }
Does anyone have any pearls of wisdom on this one?
Cheers

2002-05-03 Edit by Corion : Added formatting


In reply to File::Copy across a Network by Kibashira

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.