store() isn't uploading a file I've got this code from my file upload form.
$file_name = $request->file('file_name');
$path = $request->file('file_name')->store('uploads');
The uploads folder is set to read/write access 777. If I return $path, it gives me the right path and the new name of the file. But the file isn't on me server.
I've also tried:
$path = Storage::putFile('uploads', $request->file('file_name'));
That hasn't worked either.
What am I doing wrong?
@jerauf <form> tag contains
<form enctype="multipart/form-data" method="POST">
?
@Dry7 -
Yeah, my form is:
<form action="{{ route('saveFile') }}" method="post" enctype="multipart/form-data">
<input type="file" name="file_name">
<p><button type="submit">Upload</button>
{{ csrf_field() }}
</form>
@jerauf what returns
print_r($_FILES);
?
Sure. It's:
Array ( [file_name] => Array ( [name] => the_big_w.jpg [type] => image/jpeg [tmp_name] => /tmp/php7wwiqj [error] => 0 [size] => 190115 ) )
@jerauf check
/storage/app/uploads and
/storage/uploads
They're there! In storage/app/uploads
Thank you.
However, when I try to access the file, I'm given an error:
File `storage/app/uploads/8UpdkvL3QsiDu3oh3qILd9GO7Exhtpm9IgnnnUUr.jpeg` does not exist
And when I go to domain.com/storage/app/uploads/8UpdkvL3QsiDu3oh3qILd9GO7Exhtpm9IgnnnUUr.jpeg, I get a page not found error.
@jerauf run
php artisan storage:link
save file to
$path = $request->file('file_name')->store('public/uploads');
and use domain.com/storage/uploads/8UpdkvL3QsiDu3oh3qILd9GO7Exhtpm9IgnnnUUr.jpeg
Same result after doing that and going to domain.com/storage/app/uploads/8UpdkvL3QsiDu3oh3qILd9GO7Exhtpm9IgnnnUUr.jpeg
Please sign in or create an account to participate in this conversation.