我有一個HTML表單與一些PHP來執行一個PowerShell腳本。在php中的shell_exec的問題
所有工作正常,除了textarea輸入字段。如果我在textarea框中做了一行文本,它可以正常工作並啓動PowerShell腳本。如果我插入多行文本(包括回車符),它只會佔用第一個單詞/行並切除其餘部分。
下面是啓動PowerShell腳本命令:
在textarea的箱一個字:
powershell -command file.ps1 -textarea 'test'
用方框
powershell -command file.ps1 -textarea 'firstword
多個單詞如上所示,當TextArea字段中有多行時,它會將其剝離並僅發送第一個字。這會導致PowerShell腳本失敗,因爲終止符丟失。
任何想法?
下面是代碼:
if($isValid) {
$customerid = $_POST["DLState"];
$changesubject = $_POST['subject'];
$starttime = $_POST['starttime'];
$endtime = $_POST['endtime'];
$changedetails = $_POST['details'];
$psScriptPath = "*****";
$query = shell_exec("powershell -command $psScriptPath -username '$user' -subject '$changesubject' -orgid '$customerid' -textarea '$changedetails' -edt '$endtime' -sdt '$starttime' < NUL");
}
HTML文本區域標籤
<textarea id="txtarea" name="details" cols="40" rows="6"></textarea>
當改變我行你上面的格式,我收到以下錯誤PHP: – user137045
PHP解析錯誤:語法錯誤,意外「{」在C:\的index.php上線73 – user137045
是的,我想我們'重新丟失了一些雙引號 - 「」「 –