Execute looping bash script via PHP without interrupting server function -


i have apache server login page want pass credentials provided @ login authenticate upload of file sent server. i'm new this

when upload file server, responds 500 code. think problem autoupload.sh because when comment out line 3 of upload.php, error code ceases , uploads server work, naturally files never uploaded external service.

the point of autoupload.sh watch monitor added files /uploads/ directory, upload them webservice, delete them locally on completion, , exit.

index.php form looks

<form action="uploadpage.php" method="post"> <input name="field1" type="text"/> <input name="field2" type="password"/> <a href='/tmp/data.txt></a> //html content //more html content 

uploadpage.php contains form:

`<form action="upload.php" class="dropzone" id="my-dropzone"></form> //more html , css` 

upload.php looks like:

`$old_path=getcwd(); //preserve working directory chdir('/path/to/dir/'); shell_exec("./autoupload.sh $_post['field1'] $_post['field2']"); chrdir($old_path); //other stuff` 

and autoupload.sh looks like:

user=$1 pw=$2 while ifs= read -r file; curl -u $user:$pw -t "/path/to/$file" https://web@site.com && rm -f "path/to/$file" exit 1 done < <(inotifywait -m q -r -e moved_to --format '%f' /var/www/html/uploads/) 


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -