1
我正在開發一個個人項目,他們允許我從網上wget文件。%0D wget with php
我有一個問題,所有的文件名在末尾有一個%0D exept列表中的最後一個。
這裏是我的代碼:
的index.php:
<!DOCTYPE html>
<html>
<form action="action.php" method="post" enctype="multipart/form-data">
<textarea name="directlink" class="form-control" rows="3"></textarea>
<button type="submit" name="send" class="btn btn-default">Send</button>
</form>
</html>
action.php的:
<?php
if (isset($_POST['directlink'])) {
$file = str_replace(' ', '', $_POST['directlink']);
$files = explode("\n", $file);
foreach ($files as $value) {
$final[] = base64_encode($value);
}
$file = implode(" ", $final);
shell_exec('sudo -u user download/wget.sh ' . 'option' . ' ' . $file);
}
?>
Wget.sh:
#!/bin/bash
/download/wget_cmd.sh "[email protected]" 2>&1
Wget_cmd.sh:
#!/bin/bash
for i in ${@:2}
do
file=$(echo -n "${i}" | base64 --decode)
wget "$file" -P /download/ 2>&1
done
um,'wget.sh'應該簡單地寫成'/download/wget_cmd.sh「$ @」2>&1'。爲什麼'wget_cmd.sh'只是忽略它的第一個參數? – chepner
因爲它不是完整的腳本,我正在做一些處理與選項。我不知道爲什麼我在做2 bash腳本,謝謝x)但是問題是一樣的,我也有%0D – pehechpe
好吧,只有一個腳本,我需要在網頁上等待。我需要2個腳本來在後臺啓動wget。如果你有另一種方法..謝謝你的「$ @」的提示^^ – pehechpe