Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: file handing

by poj (Abbot)
on Sep 22, 2018 at 13:37 UTC ( [id://1222837]=note: print w/replies, xml ) Need Help??


in reply to file handing

see File::Copy

poj

Replies are listed 'Best First'.
Re^2: file handing
by bigup401 (Pilgrim) on Sep 22, 2018 at 16:17 UTC

    now the problem i have. it copies when no rename but when i try to put rename. the file gets renamed but cant be copied after rename

    use strict; use warnings; use File::Copy; my $NFILE = "09911"; my $FILE = '02190.JPG'; my $filetobecopied = $FILE; my $foldertocopyto = "img"; my $rename = rename($FILE, "$NFILE.JPG"); copy($rename, $foldertocopyto) or die "File cannot be copied.";

      see rename

      rename OLDNAME,NEWNAME
      
      Changes the name of a file; an existing file NEWNAME will be clobbered. Returns true for success, false otherwise.
      poj

        i have tried to figure it out. this is wat i mean that open function can be used instead file copy

        $IMG = $CGI->param("photo"); my $newfile = '09911.JPG'; my $copydir = 'img'; my $uploadfile = $CGI->upload($IMG); rename($uploadfile, $newfile); open ( UPLOADFILE, "+>$copydir/$newfile" ); close UPLOADFILE;

        now the code works as i like it. but i get my pics with zero bytes

Re^2: file handing
by bigup401 (Pilgrim) on Sep 22, 2018 at 13:42 UTC

    i wanted to use open() function

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1222837]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 15:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found