cmd matlab 함수에서 실행되는 PHP 파일이 있습니다. ->이 함수는 .txt 파일을 만들고 분석 결과로 채 웁니다. php 파일은이 .txt 파일을 가져 와서 정보를 문자열 (.txt에서 행)로 데이터베이스 (phpmyadmin)로 보냅니다. 내 문제는 PHP는 matlab에 파일을 쓰는 동안 .txt에서 정보를 보내기 시작합니다. matlab과 php가 알고있는 전역 변수로 문제를 해결하고 플래그가 Matlab이 필요한 파일을 빌드 할 때 플래그를 결정하는 플래그로 사용한다고 생각했습니다. 나는 윈도우 레지스트리를 사용하려고 생각했지만 매우 복잡하다. 더 쉬운 방법이 있습니까?파일 충돌을 막기 위해 Matlab
덕분에 많이, 도론
내 PHP 파일 : // 여기에
unlink('test.txt');
if(isset($_POST['filepath'])) {
$filename = $_POST['filepath'];
$inputDir = "C:\\xampp\\htdocs\\login";
$outputDir = "C:\\xampp\\htdocs\\login";
// here php open the matlab function from the cmd:
$command = "matlab -sd ".$inputDir." -r phpcreatefile2('".$outputDir."\\".$filename.".txt')";
exec($command);
$fileLoc= "".$outputDir."\\".$filename.".txt" ;
echo $fileLoc ;
echo "The following command was run: ".$command."<br/>";
echo $filename." was created in ".$outputDir."<br/>";
echo " Now the txt file will write in the DB <br/>";
나는 파일이 존재하고 비어 있지 않은 경우 있는지 확인하기 위해 노력했다. 하지만 matlab은 여전히 파일에 쓰고 있기 때문에 작동하지 않습니다.
while (1) {
if (file_exists("test.txt")){
echo "check1";
if (filesize("test.txt")!= 0) {
echo "check2";
$file = file('test.txt');
$sql = "INSERT INTO `ID_5525_Medical_record`(`Data`,`AV_Power`,`Highest_Amp`,`90BW`,`Url_figure`) VALUES ('$file[0]','$file[1]','$file[2]','$file[3]','$file[4]')" ;
if(mysqli_query($connection,$sql))
{
unlink('test.txt');
echo "the txt file is now in the DB <br/>";
}
break;
}
else {
echo "i am going to sleep";
sleep(1);
echo "i am awake";
}
}
}
`