Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background upload in PHP

I am working with a form that allows me to upload files via a local folder and FTP. So I want to move files over ftp (which already works)

Because of performance reasons I chose this process to run in the background so I use nfcftpput (linux)

In CLI the following command works perfectly: ncftpput-b-u name -p password -P 1980 127.0.0.1 /upload/ /home/Downloads/upload.zip

(Knowing that the b-parameter triggers background process) But if I run it via PHP it does not work (without the-b parameter it does)

PHP code:

$cmd = "ncftpput -b -u name -p password -P 1980 127.0.0.1 /upload/ /home/Downloads/upload.zip";
$return = exec($cmd);
like image 731
Robijntje007 Avatar asked Jul 18 '26 09:07

Robijntje007


1 Answers

Try one of the following:

1) Use the command $cmd = "ncftpput -b -u name -p password -P 1980 127.0.0.1 /upload/ /home/Downloads/upload.zip &"; (Notice the &)

2) Try php's proc_open function http://php.net/manual/en/function.proc-open.php

like image 154
Rwky Avatar answered Jul 19 '26 23:07

Rwky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!