New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Headers sending a picture in a form #55
Comments
Can you provide some example code? |
require_once 'guzzle.phar';
$client = new \Guzzle\Http\Client();
$request = $client->post('post.php')
->addPostFiles(array(
'picture' => 'path/to/image.jpg'
));
$response = $request->send(); |
A comment related to the full path: http://www.php.net/manual/en/function.curl-setopt.php#101231 And a comment about content-type: http://www.php.net/manual/en/function.curl-setopt.php#97591 |
Interesting. You'll need to set the Content-Type yourself, but I'm not sure what's going on with the Content-Disposition header. I wonder if that's an issue with curl or an implementation detail in Guzzle. I'll need to find some time to investigate further. |
Well, using a normal browser, users don´t need to set the Content-Type for their upload files. So Guzzle should detect Content-Type too. |
There's some Content-Type guessing functionality that I suppose I could refactor so that it attempts to guess the content-type for POST uploads: https://github.com/guzzle/guzzle/blob/master/src/Guzzle/Http/EntityBody.php#L110 I'm not sure why you're getting a reference to a temp file. I'll look into that sometime this week. However, I don't think it would be an issue to send the full path to a file. The |
Cool, it would be nice to have the auto-detecting. According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html (19.5.1 Content-Disposition):
More here: http://www.ietf.org/rfc/rfc1806.txt (2.3 The Filename Parameter) |
I'm running into the same issue as @yosmanyga did originally. The filename is getting sent with it's full path to the server, and this is not correct. It should only display the file selected to be uploaded. Anyways, I'm sure I have the newest cost since I get this via composer. What gives? |
Found a way to workaround this with cURL. The master branch has a fix for this now and will strip out the leading slash on the filename portion of the Content-Disposition header. |
I'm submitting a form with a picture. Using a browser I get this:
But using guzzle I get this:
Any bug here?
The text was updated successfully, but these errors were encountered: