the audio failed to upload just in production server it works correctly in my local environment.
error : 422 Unprocessable Entity "The audio failed to upload."
i updated upload_max_filesize and post_max_size in php.ini and client_max_body_size 100M;
in nginx conf but still same error
here is the upload controller the problem is in the validation
class UploadController extends Controller
{
public function store(Request $request)
{
$request->validate([
'file' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'audio' =>'nullable|file|mimes:audio/mpeg,mpga,mp3,wav,aac'
]);
here is when i try to dd($request) before validation
+files: Symfony\Component\HttpFoundation\FileBag {#48
#parameters: array:1 [
"audio" => Symfony\Component\HttpFoundation\File\UploadedFile {#33
-test: false
-originalName: "bodak-yellow-official-music-video.mp3"
-mimeType: "application/octet-stream"
-error: 1
path: ""
filename: ""
basename: ""
pathname: ""
extension: ""
realPath: "/var/www/sportMA/web/public"
@jaseofspades88 yes I know but validation it doesn't pass any error in my local env this error just in production the problem might be in size config in nginx
The file size is only relevant in this case if you have a filesize validation rule and the file you're attempting to upload is too large. The simple fact of the matter is that a 422 Unprocessable Entity is, always has been and always will be a validation related issue.
I can see from your horrifically formatted code (I suggest you read a markdown cheatsheet to know how to format your code) that you're not passing the correct mime type of video file anyway...
I do hope, once you resolve this validation issue, you're not going to use this thread as some sort of scratch pad for... '....and now I have this problem....' and so on.
@ista0x1 You’ve set MIME type validation to audio/mpeg,mpga,mp3,wav,aac (which doesn’t seem to be a list of valid MIME types in the first place), but then try and upload a file with a MIME type of application/octet-stream, which is essentially just raw bytes rather than an actual MP3 file.
The error "The audio failed to upload" is likely due to the "file" validation rule. Likely the file you are trying to upload is not reaching the server. Try to increase the post_max_size and upload_max_filesize in the php.ini your server uses to reasonable values.
Keep in mind that a very big file might fail uploading also due to a timeout, depending on the user's connection speed. I would suggest implementing a chunked upload if you expect to deal with large files.