사람들이 jpgraph를 사용하여 일부 처리 후에 플롯되는 데이터 파일을 업로드 할 수있는 웹 사이트를 만들어야합니다. 이 파일은 analfile.sh라는 bash 스크립트로 분석됩니다. bash는 스크립트는 다음과 같다 : 1321290921.dat : 동적 파일 이름이있는 fopen이 작동하지 않습니다.
#!/bin/bash
file=$1
fecha=`date +%s`
mv $1 $fecha.dat
echo $fecha.dat
그래서, 그것은 이름이 같은 또 다른 파일을 다시 제공합니다. 그게 음모를 꾸미는 데 필요한 파일입니다.
이 현재 PHP 코드 :
$target_path = "/home/myhome";
$target_path = $target_path . basename($_FILES['rdata']['name']);
$target_file = basename($_FILES['rdata']['name']);
if(move_uploaded_file($_FILES['rdata']['tmp_name'], $target_path)) {
echo "The file ". $target_file. " has been uploaded";
chdir('/home/myhome');
$filetoplot=shell_exec('./analfile.sh'.' '.$target_file);
} else{
echo "There was an error uploading the file, please <a href=\"index.html\">try again!
</a>";
}
//$filetoplot="1321290921.dat"
echo "<br>The file to be opened is ". $filetoplot. "<br>";
if ($file_handle = fopen("$filetoplot", 'r')) {
while ($line_of_text = fgets($file_handle)) {
$parts = explode('.', $line_of_text);
echo $line_of_text ;
print $parts[0] . $parts[1]. $parts[2]. "<br>";
}
fclose($file_handle);
}
본인은 대상 디렉토리에 쓸 수있는 권한을가집니다. 나는 $ filetoplot = "1321290921.dat"줄을 주석 처리하지 않으면 스크립트가 완벽하게 작동한다는 것이 이상하다고 생각합니다. 나는 PHP에서 내 첫 코드이기 때문에 내가 어리석은 짓을하고있는 것 같아요. 그러나 몇 시간 동안 인터넷 검색을 한 후에 솔루션을 찾을 수 없었습니다.
도움이 될 것입니다.
PHP를 안전 모드로 실행하고 있지 않은지 다시 한 번 확인하십시오. –