nategood / httpful

A Chainable, REST Friendly, PHP HTTP Client. A sane alternative to cURL.
MIT License
1.74k stars 299 forks source link

file upload problem. #214

Open JefferyWong opened 8 years ago

JefferyWong commented 8 years ago

I got a file upload API in java which need a MuitipartFile request param I use Httpful send a file like $url = "upload url"; $params = ['file'=>'@'.$_FILE['image']['tmp_name']]; $response = Request:post($url, $params, Mime::UPLOAD)->send(); But didn't got what I want. Is my code has problem or something wrong about Httpfull? Wish somebody answer me, kind of in hurry. thanks.

svenluijten commented 8 years ago

There's a little mistake in your code:

$url = "upload url";
$params = ['file' => '@' . $_FILE['image']['tmp_name']];

$response = Request::post($url, $params, Mime::UPLOAD)->send(); // Notice the 2 colons (::) after Request

If that doesn't fix it, can you post the error you're getting? Nobody will be able to help you without a little more background.

JefferyWong commented 8 years ago

Thank you. I've find the problem I got. PHP after version 5.6 doesn't surpport '@'.'file _path' to send file via curl. I have to use CurlFile Class to do that.

jrpeters89 commented 7 years ago

Hey @JefferyWong - would you mind sharing what you did to get this to work with Httpful? I am having an issue with the same thing. The file doesn't get into the $_FILES variable at all.