Re: Deleting a file after download/upload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi there Shawn,
Thank you for your help. That works.

-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com
"Shawn McKenzie" <nospam@xxxxxxxxxxxxx> wrote in message 
news:EE.3D.36467.C02614A4@xxxxxxxxxxxxxxx
> Parham Doustdar wrote:
>> Hi there,
>> I am writing a PHP FTP client for my project. I want to put a "download" 
>> option and an "upload"" option, but I don't know how. My problem is this:
>> How can I make the server the PHP script is on delete the file after 
>> uploading it to the SFTP, or after the user has finished downloading it 
>> from the server the PHP script is on?
>> Let me put the question this way.
>> My server connects to an FTP. Then, it downloads a file from the FTP, and 
>> then sends me the link to that temperary file on the server. Now, when I 
>> download it from my server, my script should delete the file. How can I 
>> make it wait until the download of the file is finished?
>> Same goes for uploading.
>> Thanks!
>>
>
> Well if you write a download script, then you can delete it at the end
> and it won't be deleted until after the download completes:
>
> //Do your ftp from remote to local'/path/to/file.ext'
> exec('ftp_get.sh remotefile.ext /path/to/file.ext);
> //or
> $conn_id = ftp_connect($ftp_server);
> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
> ftp_gett($conn_id, '/path/to/file.ext', $server_file, FTP_BINARY)
> ftp_close($conn_id);
>
> <?php
> //send proper headers for download
> readfile('/path/to/file.ext');
>
> unlink('/path/to/file.ext');
> ?>
>
> For upload, depending upon how you're doing it, a call to unlink()
> shouldn't execute until your FTP is done and exited:
>
> <?php
> //User uploads file to '/path/to/file.ext'
>
> exec('ftp_put.sh /path/to/file.ext);
> //or
> $conn_id = ftp_connect($ftp_server);
> $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
> ftp_put($conn_id, $server_file, '/path/to/file.ext', FTP_BINARY)
> ftp_close($conn_id);
>
> unlink('/path/to/file.ext');
> ?>
>
> -- 
> Thanks!
> -Shawn
> http://www.spidean.com 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux