Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When attempting to upload a file in development on Laravel 5 I get stream_socket_sendto(): error

I am trying a simple upload from a file so that a country has a sound file for its anthem attached. I am using PHP 7.2.10 with Laravel 5.7.19.

My form includes a field named anthem and the form commences with

<form id="form-app" enctype="multipart/form-data"
      method="post"
      action="{{ route('storeCountryAnthemMPOnly',['id' => $co->id]) }}">

The route in web.php is:

Route::post('storeCountryAnthemMPOnly/{id}',
            'CountryController@storeCountryAnthemMPOnly')
       ->name('storeCountryAnthemMPOnly');

and my function in the controller is just:

public function storeCountryAnthemMPOnly(Request $request, $id)
{
  dd($request);
}

When I press the submit button I am getting:

stream_socket_sendto(): A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.

I cannot understand this and help is greatly appreciated.

like image 679
Jim Avatar asked Dec 26 '18 12:12

Jim


1 Answers

File can't be uploaded to the server and it is not the fault of laravel, but your server.

I had the same problem with the same environment. The thing was the file was too large, so it couldn't be uploaded to the temporary location. Although the file wasn't uploaded to the server, laravel still was trying to read it so this is why you get "no address was supplied".

In my case file couldn't be uploaded, because of exceeding size limits, but perhaps in your case, it is another reason why the file cannot be uploaded.

I solved it by changing size and memory limits in php.ini.

memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M

Besides size limits, I have one more suggestion: make sure that you have proper permissions to the folder with temporary uploads.

You can also check server logs.

like image 138
Artur Nawrot Avatar answered Oct 21 '22 16:10

Artur Nawrot