0
我试图下载文件通过Icecat数据表。该文件需要下载访问权限。如何通过file_get_content或curl正确获取文件
我的问题是:
- 的file_get_content一点儿也不下载文件。我的目录在777上,路径是正确的。
如果我将文档插入到目录中,则文件不会被解压缩。
public function getIceCatFile() { set_time_limit (0); $url = 'https://data.Icecat.biz/export/freexml/EN/daily.index.xml.gz'; $context = stream_context_create(array('http' => array('header' => "Authorization: Basic " . base64_encode($this->username . ":" . $this->password)))); if ($this->checkDirectoryIceCat() === true) { // does'nt download the file inside the server directory file_get_contents($url, true, $context); $file = $this->IceCatDirectory . 'daily.index.xml.gz'; if (is_file($file)) { $zip = new \ZipArchive; // error failed same if I include the file inside the directory $icecat_file = $zip->open($this->IceCatDirectory . 'files.index.xml.gz'); if ($icecat_file === true) { $zip->extractTo($icecat_file); $zip->close(); echo 'file downloaded and unzipped'; } else { echo 'failed'; } } else { echo 'error no file found in ' . $file; } } }