I want to upload a file in laravel 5. Actually I did it well, the file is saved. But, when the name of the file include "/" in it, the file won't upload. example when my name file is "test/test.pdf" it just save the name in the database but don't the file. When I am tring to view file, the link become "localhost/laravel/public/files/test/test" and error messages. Do you know how to fix it? and do you know how to make it only pdf files which can be uploaded and the maximum size of it is not more than 1MB.
Here is my upload function in controller:
public function uploadsurat(Request $request)
{
$destination = 'files';
if($request->hasFile('upload_file')) {
$file = $request->file('upload_file');
$extension = $file->getClientOriginalExtension();
$file_name = $request['nomor_surat'] . '.' . $extension;
$file->move($destination, $file_name );
}
$upload_file = $file_name;
$surat->upload_file = $upload_file;
$surat->save();
return redirect('suratbaru');
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/26Nf8TS
via IFTTT
Aucun commentaire:
Enregistrer un commentaire