我正在尝试使用HttpRequest类执行 HTTP POST 并从本地 php 脚本发送文件。testupload.php 的代码是:
<?php
$r = new HttpRequest('http://127.0.0.1:5090/upload.php', HttpRequest::METH_POST);
$r->addPostFile('app', 'abc.txt');//if this line is commented the exception is gone
try {
echo $r->send()->getBody();
} catch (HttpException $ex) {
echo $ex;
}
?>
我在以下情况下遇到以下异常:
exception 'HttpInvalidParamException' with message 'Empty or too short HTTP message: ''' in
D:\xampp\htdocs\testupload.php:0 inner exception 'HttpRequestException' with
message 'Failed to open/read local data from file/application; failed creating formpost
data (http://127.0.0.1:5090/upload.php)' in D:\xampp\htdocs\testupload.php:8
Stack trace: #0 D:\xampp\htdocs\testupload.php(0): HttpRequest->send() #1 {main}
文件 abc.txt 位于同一目录中。问题是什么??