Hello, dear programmers)
The task - it is necessary from one project to yii2 upload file to another project also in yii2. The point is that the file CANNOT be transferred in the open (ie give a link to the file, and the second project kurlon or anything to download).
I kinda dug up this way:
Yii::$app->response->sendFile($path, $model->file ['mimeType'=>'application/zip']);
But how can I make the second server the whole thing?)
...MB something like this? But cheto not)
private function download($url, $file) { $myFile = @fopen($file, "w"); $resource = curl_init(); curl_setopt($resource, CURLOPT_URL, $url); curl_setopt($resource, CURLOPT_FILE, $myFile); curl_setopt($resource, CURLOPT_HEADER, 0); curl_exec($resource); curl_close($resource); fclose($myFile); }
Question add one important detail.
"Loading-file-in-framework-rest-json-concept"