I need a way to copy a file from point A to point B. I have tried to use File::Copy but for some reason my file didn't get moved.
my $location = "/home/name/public_html/header.gif"; my $temp_folder_path = "/home/name/public_html/test.gif"; copy("$location","$temp_folder_path\test.gif");
Perhaps what I'm trying to do in one step requires two? (copying the file over and renaming it).

Along with this I need your monkly advice. This is part of a file downloading script for a members section. It takes a list of files from the database and then writes a random file name for them. This is to prevent people from giving the actual URLs of our files out since the filenames will always be different they won't be able to.

By having a list of links to push and then have the script copy a file from one part of the server to the other seems a little costly. Especially if they have say 10MB files or greater. Then I think we're totally doing something wrong.

Our first idea was to copy the file they selected with a random name to a /temp/ folder. But again the problems we are having is 1) it doesn't seem to be working 2) the overhead of large files and 3) how would you delete the file once it's been opened? We want it there just long enough so they can view it on their screen but they can't reload it without going through the link process again.

Any and all advice on this would be very much appreciated.


In reply to Copying files 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.