Closed
Description
i have this code, which i use in laravel 4 to upload and validate a file ( and they assure to me that this is related to Symfony HttpFoundation laravel/framework#1968 (comment) )
<?php
class HomeController extends BaseController {
public function getIndex()
{
return View::make('hello');
}
public function postAddFile(){
$file = Input::file('pod');
$files = array('file'=>Input::file('pod') );
$rules = array('file'=>'required|mimes:mp3');
echo 'File : '.$file->getClientOriginalName().'<br />';
echo 'Mime : '. $file->getMimeType().'<br />';
echo 'Ext : '. $file->guessExtension().'<br />';
$validate = Validator::make($files,$rules);
if($validate->passes()){
echo 'Mime : '. $file->getMimeType().'<br />';
}else{
var_dump($validate->messages());
}
$file->move(storage_path().'/cache', $file->getClientOriginalName());
}
}
which am use to validate the file which am uploading ..
but sadly the result is this :
File : test.mp3
Mime : audio/mpeg
Ext : mpga
object(Illuminate\Support\MessageBag)#151 (2) { ["messages":protected]=> array(1) { ["file"]=> array(1) { [0]=> string(37) "The file must be a file of type: mp3." } } ["format":protected]=> string(8) ":message" }
as every one see the validation failed to read the extension of the file, and the result of the $file->guessExtension()
is mpga
mean while it should be mp3
..
so am not so sure what is the problem here, and if this is something related to php configuration ..
my server is ubuntu with php 5.3
Metadata
Metadata
Assignees
Labels
No labels