File upload using guzzle client I am doing like following :
$request = $this->client->post($url, ['upload'=>'@'.$filepath], $options);
i want to upload file using guzzle and i am not using any form, using above post request file not getting uploaded, i just need data of uploaded file data like size, tmp_name inside $_FILES array
$fileContent = File::get($filepath);
$request = $this->client->post($url, [
'multipart' => [
[
'name' => 'upload',
'contents' => $fileContent,
'filename' => end(explode('/', $filepath)),
],
],
]);
@Yorki
Thanks for your reply but I am getting Fatal error like
Class 'QuickEmailVerification\Api\File' not found
How can I solve this??
Add use clause to your controller
use File;
@Yorki , Sorry for inconvenience, but i Added that Line but now error coming like
Class 'File' not found
Try
use Illuminate\Support\Facades\File;
@Yorki , getting same error
Class 'Illuminate\Support\Facades\File' not found
Are you even using Laravel framework to do this? If not then just use native php function
$fileContent = file_get_contents($filepath);
@Yorki , This is working but still file not getting uploaded.
Are you trying to upload file to an API, script or Laravel Controller? Is upload desired field name of uploaded file?
I am trying to upload file to API, but i am not using any form, without form need to upload file.
Is this API public? If so send me link to this endpoint documentation
No, this is not public API
@Yorki
If i pass path of the file then i just need data like following with file upload and i am not using any form here
[upload] => Array
(
[name] => testEmail.csv
[type] => application/octet-stream
[tmp_name] => /tmp/php5cbtni
[error] => 0
[size] => 61
)
I don't know what are you trying to achieve exactly, can't you just use filesize() and mime_content_type()? This isn't even related to Laravel at all :)
@Yorki
I am not using laravel, i am using only php
All i just need to upload file without from using guzzle.
Please sign in or create an account to participate in this conversation.