Wie machen Post-Anfrage mit GuzzleHttp (Version 6.0). Ich versuche, die folgenden Schritte aus und bekommen FehlerPHP GuzzleHttp. Wie lade ich die Image-Datei mit guzzlehttp in Laravel 5.2 hoch?
Ich bin der Bildwert
Illuminate\Http\UploadedFile Object
(
[test:Symfony\Component\HttpFoundation\File\UploadedFile:private] =>
[originalName:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 1.53mb.jpg
[mimeType:Symfony\Component\HttpFoundation\File\UploadedFile:private] => image/jpeg
[size:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 1607671
[error:Symfony\Component\HttpFoundation\File\UploadedFile:private] => 0
[pathName:SplFileInfo:private] => C:\wamp\tmp\php32BB.tmp
[fileName:SplFileInfo:private] => php32BB.tmp
)
hier ich verwende guzzlehttp mit dem Bild hochladen
$response = $this->client->request('POST', url('/update_profile'), [
'multipart' => [
[
'name' => 'foo',
'contents' => fopen('C:\wamp\tmp\php32BB.tmp', 'r'),//this path is image save temperary path
]
]
]);
i den Fehler Jetzt erhalten fopen (C: \ wamp \ tmp \ php17BC.tmp): Fehler beim Öffnen des Streams: Keine Datei oder Verzeichnis.
Wie die Inhalt in mehrteiliger
Haben Sie C: \ wamp \ tmp-Ordner erstellt? fopen würde das Verzeichnis für Sie nicht erstellen, wenn es nicht existiert. – SteD
Dieses Problem wurde behoben $ image_path = $ post_array ['image'] -> getPathname(); $ image_mime = $ post_array ['bild'] -> getmimeType(); $ image_org = $ post_array ['bild'] -> getClientOriginalName(); $ response = $ this-> client-> Post (url ('/ update_profile'), [ \t \t \t 'mehrteiliger' => [ \t \t \t \t [ \t \t \t \t \t 'name' => 'Bild', \t \t \t \t \t 'Dateiname' => $ image_org, \t \t \t \t \t 'Mime-Type' => $ image_mime, \t \t \t \t \t 'Inhalt' => fopen ($ image_path 'r'), \t \t \t \t], \t \t \t] \t \t]); – boopathi008
Mögliches Duplikat von [Fehler beim Öffnen des Streams: Keine solche Datei oder kein Verzeichnis] (http://stackoverflow.com/questions/36577020/failed-to-open-stream-no-such-file-or-directory) –