Reputation: 35
I tried to upload file by this code:
controller:
public function fileupload (Request $request)
{
$file = $request->file('image');
echo 'File Name: '.$file->getClientOriginalName();
echo 'File Real Path: '.$file->getRealPath();
$file->move('uploads', $file->getClientOriginalName());
}
view:
<html>
<body>
<?php
echo Form::open(array('url' => '/fileupload','files'=>'true'));
echo 'Select the file to upload';
echo Form::file('image');
echo Form::submit('Upload File');
echo Form::close();
?>
</body>
</html>
and after that I receive this message:
File Real Path: /private/var/folders/d0/b3zwsx7530l115k5rrj0zkx80000gn/T/phpdDRwaz
but I cant find my file. What is the path and how can I access it?
Upvotes: 0
Views: 10734
Reputation: 345
You can find out default file upload path (storage_path) from
/config/filesystems.php
You can change that as per your requirements.
Hope this helps you.
Upvotes: 0
Reputation: 577
update some code in your project so that you can easily upload and find the file real parh
$path = public_path('products/images/');
File::makeDirectory($path, $mode = 0777, true, true);
$file = $request->file('image');
$archivo = value(function() use ($file){
$filename = str_random(10) . '.' . $file->getClientOriginalExtension();
return strtolower($filename);
});
$file->move($path, $archivo);
The Upload file is find inside your laravel public/images folder hope this will help you Thanks
Upvotes: 0
Reputation: 4461
You are checking the file path before uploading the file, so check the folder uploads which is present in the storage folder in root.
storage\app\uploads
Upvotes: 1