Here is something simpler still can't get it to work. in HTML 5 ajax uploader
public function upfle(){
$file = Input::file('files');
$destinationPath = '/public/uploads/';
$ext = $file->guessClientExtension(); // Get real extension according to mime type
$fullname = $file->getClientOriginalName(); // Client file name, including the extension of the client
$hashname = date('H.i.s').'-'.md5($fullname).'.'.$ext; // Hash processed file name, including the real extension
$upload_success = Input::file('files')->move($destinationPath, $hashname);
}
The code is working now
/*Upload Images */
public function upload_file(){
$file = Input::file('files');
$allowed_ext = array('jpg','jpeg','png','gif');
$ext= $file->guessClientExtension(); // Get real extension according to mime type
$fullname = $file->getClientOriginalName(); // Client file name, including the extension of the client
$hashname =substr_replace(sha1(microtime(true)), '', 12).'.'.$ext;
$destinationPath = 'assets/uploads/';
if(!in_array($ext,$allowed_ext)){
echo json_encode(array('status'=>'Invalid File Extension'));
}
else{
$upload_success = Input::file('files')->move($destinationPath, $hashname);
}
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community