在Angular到PHP的文件上传过程中,如果CORS头部不起作用,可以尝试以下解决方法:
import { HttpClient } from '@angular/common/http';
// ...
constructor(private http: HttpClient) { }
uploadFile(file: File) {
const formData = new FormData();
formData.append('file', file);
return this.http.post('http://example.com/upload.php', formData, { withCredentials: true });
}
确保将http://example.com替换为你的Angular应用的URL。
;extension=php_curl.dll
;extension=php_openssl.dll
保存文件后,重启Web服务器。
请注意,这些解决方法可能需要根据你的具体情况进行适当调整和修改。