Answer the question
In order to leave comments, you need to log in
How to write a file to a specific directory in Bitrix?
Hello!
A question. The file is saved to the folder from which the script is called.
When trying to specify a different path, the file is not saved anywhere.
Here is the code
function GetImageByURL($url,$sid) {
//$path="/wav/".$sid . ".wav";
$path=$sid . ".wav";
$opts = array(CURLOPT_URL => $url, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10);
$ch = curl_init();
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200 ) {
$file = $path;
file_put_contents($file, $result);
}
curl_close($ch);
return $path;
}
Answer the question
In order to leave comments, you need to log in
try specifying full let
$_SERVER["DOCUMENT_ROOT"]
function GetImageByURL($url,$sid) {
$path=$_SERVER["DOCUMENT_ROOT"]."/wav/".$sid . ".wav";
//$path=$sid . ".wav";
$opts = array(CURLOPT_URL => $url, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 10);
$ch = curl_init();
curl_setopt_array($ch, $opts);
$result = curl_exec($ch);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200 ) {
$file = $path;
file_put_contents($file, $result);
}
curl_close($ch);
return $path;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question