Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Upload and Delete

by Dany (Initiate)
on Mar 05, 2002 at 14:29 UTC ( [id://149375]=perlquestion: print w/replies, xml ) Need Help??

Dany has asked for the wisdom of the Perl Monks concerning the following question:

I have a Perl program that upload a file from local Pc to a Unix Server. This program work well. But I'd like deleted the local file, after the file was upload to Unix Server. It is possible

Replies are listed 'Best First'.
Re: Upload and Delete
by virtualsue (Vicar) on Mar 05, 2002 at 15:12 UTC
    The Perl function unlink can be used to delete files. Use of unlink will fail if your program doesn't have the necessary authority over the file(s) to be deleted.
      Ok, thanks, but unlik works in the machine that run the Perl CGI. The Perl CGI run in Unix Server.
        You should be able to use unlink on a PC, so there must be something else wrong. Without knowing anything about what you're doing, it's hard to say.

        Are you using die with $! to show you why the system couldn't perform the unlink? e.g.
        unlink $file or die "Can't delete $file, $!"

        If not, add that and see if it doesn't give you the help you need. If you reply to this thread again, you'll save a lot of time by explaining what you are doing in more detail and including some relevant code.
Re: Upload and Delete
by earthboundmisfit (Chaplain) on Mar 05, 2002 at 15:07 UTC
    Perhaps I don't understand the question, but I'm reading it that you want to delete a file that is stored on the same PC that the Perl script is running on. If this is the case, perlfunc->unlink is your friend.
(jeffa) Re: Upload and Delete
by jeffa (Bishop) on Mar 05, 2002 at 15:02 UTC
    I'll second steves's reply. If you really need to send a local file to a remote server and then delete that local file, then you should read up on Net::FTP (which should already be installed in your Perl distro) or Net::FTP::Common.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: Upload and Delete
by steves (Curate) on Mar 05, 2002 at 14:51 UTC

    There's no way to do this. Certainly not with the Perl CGI which is running on the server. And no client side language is going to provide access to the local file system unless there's some huge security hole.

    Imagine for a minute that you could connect to web sites and have them delete your files. Ask yourself if you'd ever go to those sites.

      Just a few quick comments:
      • I never saw a mention of CGI in the context of his question
      • Maybe the local file is on his PC, where the script is also running
      I may well be off base here, but I think he would just like to clean up his PC after the upload is complete.

        You are correct. I jumped to that CGI conclusion when I saw the word "upload". Dany, how about some code here? I may have been off base assuming CGI.

        Thanks virtualsue ...

      I understand your words. But is for a local aplication not for a publish in a WWW. Thanks.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-23 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found