У меня есть переменная с путем Windows и обратными слешами.И в этом мне нужны две другие переменные.Выглядит так:
$file_name_with_full_path = 'C:\inetpub\wwwroot\upload\files\$filnr\$file';
В конце мне нужны переменные $ filnr и $ file, но это невозможно сделать с помощью ""
$file_name_with_full_path = "C:\inetpub\wwwroot\upload\files\$filnr\$file";
С "" iЯ получил ошибку, потому что в моем скрипте я делаю curl-запрос.
Как мне вставить переменные с обратной косой чертой в один '?
мой полный скрипт выглядит так:
if ($result->num_rows > 0) {
//schleife ausführen
while($row = $result->fetch_assoc()) {
//ip und filnr aus datenbank in var
$ip = $row["ip"];
$filnr = $row["filnr"];
echo "$filnr $ip<br>";
//filnr und dateiname momentan noch hart codiert
$target_url = "http://10.74.20.94:6001/upload";
$file_name_with_full_path = 'C:\inetpub\wwwroot\upload\files\$filnr\$file';
if (function_exists('curl_file_create')) {
$cFile = curl_file_create($file_name_with_full_path);
} else {
$cFile = '@' . realpath($file_name_with_full_path);
}
$post = array('targetpath'=>'C:\bizstorecard\hossi','uploadfile'=> $cFile);
$go = curl($target_url,$post);
}
} else {
echo "Fehler bei Abfrage";
}
function curl($target_url,$post) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_exec($ch);
curl_close($ch);
}