Level 88
Probably because the getClientOriginalExtension returns a different extension than expected! Have you looked into that?
Hey guys, if i upload mp3 file, why its auto convert to .mpga file?
here is my code
public function addTrack($id, Request $request)
{
$this->validate($request, [
'files' => 'required'
]);
$album = $this->albumRepo->findAlbumById($id);
$files = $request->file('files');
if($request->hasFile('files')) {
$getid3 = new \getID3();
foreach ($files as $key => $file) {
$file_name = preg_replace('/\.[^.\s]{3,4}$/', '', $file->getClientOriginalName());
$extension = $file->getClientOriginalExtension();
$albumName = str_slug($album->name).'_'.$album->id;
$path = $file->store('track_files/'.$albumName);
$analyze = $getid3->analyze($path);
$album->tracks()->create([
'name' => $file_name,
'slug' => str_slug($file_name),
'number' => ++$key,
'popularity' => 50,
'path' => $path,
// 'duration' => $analyze['bitrate'],
// 'playtime' => $analyze['playtime_string'],
]);
}
}
return redirect()->back()->with('message', trans('store'));
}
Thank you
Please or to participate in this conversation.