Upload movies with Laravel
up vote
1
down vote
favorite
I get this error when I try to upload movie/video on my site 'You don't have permission to access the requested directory. There is either no index document or the directory is read-protected'. Here is my code
view:
<div class="col-md-6">
{!! Form::open(['method'=>'POST', 'action'=> 'MovieController@store', 'files' => true]) !!}
<div class="form-group">
{!! Form::label('movie_name', 'Select Movie:') !!}
{!! Form::file('movie_name', null, ['class'=>'form-control'])!!}
</div>
</div>
controller:
public function store(Request $request){
$data = $request->all();
if ($request->hasFile('movie_name')) {
$file = $request->file('movie_name');
$name = $file->getClientOriginalName();
$data[ 'movie_name' ] = $name;
$destination = '/public/movies';
$request->file('movie_name')->move(base_path() . $destination, $name);
return $name;
} else {
return false;
}
}
php laravel upload
add a comment |
up vote
1
down vote
favorite
I get this error when I try to upload movie/video on my site 'You don't have permission to access the requested directory. There is either no index document or the directory is read-protected'. Here is my code
view:
<div class="col-md-6">
{!! Form::open(['method'=>'POST', 'action'=> 'MovieController@store', 'files' => true]) !!}
<div class="form-group">
{!! Form::label('movie_name', 'Select Movie:') !!}
{!! Form::file('movie_name', null, ['class'=>'form-control'])!!}
</div>
</div>
controller:
public function store(Request $request){
$data = $request->all();
if ($request->hasFile('movie_name')) {
$file = $request->file('movie_name');
$name = $file->getClientOriginalName();
$data[ 'movie_name' ] = $name;
$destination = '/public/movies';
$request->file('movie_name')->move(base_path() . $destination, $name);
return $name;
} else {
return false;
}
}
php laravel upload
chmod ? stackoverflow.com/a/37266353/2693543
– Shobi
Nov 13 at 13:22
try to give permission to upload directory via chmod -R 777 uploadsdir
– Hemant Kumar
Nov 13 at 13:24
I have full control on the upload directory. It still shows the same mistake
– Gacho
Nov 13 at 13:27
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I get this error when I try to upload movie/video on my site 'You don't have permission to access the requested directory. There is either no index document or the directory is read-protected'. Here is my code
view:
<div class="col-md-6">
{!! Form::open(['method'=>'POST', 'action'=> 'MovieController@store', 'files' => true]) !!}
<div class="form-group">
{!! Form::label('movie_name', 'Select Movie:') !!}
{!! Form::file('movie_name', null, ['class'=>'form-control'])!!}
</div>
</div>
controller:
public function store(Request $request){
$data = $request->all();
if ($request->hasFile('movie_name')) {
$file = $request->file('movie_name');
$name = $file->getClientOriginalName();
$data[ 'movie_name' ] = $name;
$destination = '/public/movies';
$request->file('movie_name')->move(base_path() . $destination, $name);
return $name;
} else {
return false;
}
}
php laravel upload
I get this error when I try to upload movie/video on my site 'You don't have permission to access the requested directory. There is either no index document or the directory is read-protected'. Here is my code
view:
<div class="col-md-6">
{!! Form::open(['method'=>'POST', 'action'=> 'MovieController@store', 'files' => true]) !!}
<div class="form-group">
{!! Form::label('movie_name', 'Select Movie:') !!}
{!! Form::file('movie_name', null, ['class'=>'form-control'])!!}
</div>
</div>
controller:
public function store(Request $request){
$data = $request->all();
if ($request->hasFile('movie_name')) {
$file = $request->file('movie_name');
$name = $file->getClientOriginalName();
$data[ 'movie_name' ] = $name;
$destination = '/public/movies';
$request->file('movie_name')->move(base_path() . $destination, $name);
return $name;
} else {
return false;
}
}
php laravel upload
php laravel upload
asked Nov 13 at 13:20
Gacho
238
238
chmod ? stackoverflow.com/a/37266353/2693543
– Shobi
Nov 13 at 13:22
try to give permission to upload directory via chmod -R 777 uploadsdir
– Hemant Kumar
Nov 13 at 13:24
I have full control on the upload directory. It still shows the same mistake
– Gacho
Nov 13 at 13:27
add a comment |
chmod ? stackoverflow.com/a/37266353/2693543
– Shobi
Nov 13 at 13:22
try to give permission to upload directory via chmod -R 777 uploadsdir
– Hemant Kumar
Nov 13 at 13:24
I have full control on the upload directory. It still shows the same mistake
– Gacho
Nov 13 at 13:27
chmod ? stackoverflow.com/a/37266353/2693543
– Shobi
Nov 13 at 13:22
chmod ? stackoverflow.com/a/37266353/2693543
– Shobi
Nov 13 at 13:22
try to give permission to upload directory via chmod -R 777 uploadsdir
– Hemant Kumar
Nov 13 at 13:24
try to give permission to upload directory via chmod -R 777 uploadsdir
– Hemant Kumar
Nov 13 at 13:24
I have full control on the upload directory. It still shows the same mistake
– Gacho
Nov 13 at 13:27
I have full control on the upload directory. It still shows the same mistake
– Gacho
Nov 13 at 13:27
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
Use Laravel's asset helper method to point to the public folder.
Try this:
public function store(Request $request){
$data = $request->all();
if ($request->hasFile('movie_name')) {
$file = $request->file('movie_name');
$name = $file->getClientOriginalName();
$data[ 'movie_name' ] = $name;
$request->file('movie_name')->move(asset('movies'), $name);
return $name;
} else {
return false;
}
}
Still the same mistake.
– Gacho
Nov 13 at 13:49
Again, same thing.
– Gacho
Nov 13 at 15:44
In that case, it's a permissions thing then. Kindly crosscheck the permissions on the folder and if the server has rights to create files or not.
– Peter Sowah
Nov 14 at 11:27
add a comment |
up vote
0
down vote
Try changing '/public/movies' permissions to 775.
sudo chmod -R 775 PATH/TO/DIRECTORY
I am using windows, and have full control over permissions.
– Gacho
Nov 13 at 15:45
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Use Laravel's asset helper method to point to the public folder.
Try this:
public function store(Request $request){
$data = $request->all();
if ($request->hasFile('movie_name')) {
$file = $request->file('movie_name');
$name = $file->getClientOriginalName();
$data[ 'movie_name' ] = $name;
$request->file('movie_name')->move(asset('movies'), $name);
return $name;
} else {
return false;
}
}
Still the same mistake.
– Gacho
Nov 13 at 13:49
Again, same thing.
– Gacho
Nov 13 at 15:44
In that case, it's a permissions thing then. Kindly crosscheck the permissions on the folder and if the server has rights to create files or not.
– Peter Sowah
Nov 14 at 11:27
add a comment |
up vote
2
down vote
accepted
Use Laravel's asset helper method to point to the public folder.
Try this:
public function store(Request $request){
$data = $request->all();
if ($request->hasFile('movie_name')) {
$file = $request->file('movie_name');
$name = $file->getClientOriginalName();
$data[ 'movie_name' ] = $name;
$request->file('movie_name')->move(asset('movies'), $name);
return $name;
} else {
return false;
}
}
Still the same mistake.
– Gacho
Nov 13 at 13:49
Again, same thing.
– Gacho
Nov 13 at 15:44
In that case, it's a permissions thing then. Kindly crosscheck the permissions on the folder and if the server has rights to create files or not.
– Peter Sowah
Nov 14 at 11:27
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Use Laravel's asset helper method to point to the public folder.
Try this:
public function store(Request $request){
$data = $request->all();
if ($request->hasFile('movie_name')) {
$file = $request->file('movie_name');
$name = $file->getClientOriginalName();
$data[ 'movie_name' ] = $name;
$request->file('movie_name')->move(asset('movies'), $name);
return $name;
} else {
return false;
}
}
Use Laravel's asset helper method to point to the public folder.
Try this:
public function store(Request $request){
$data = $request->all();
if ($request->hasFile('movie_name')) {
$file = $request->file('movie_name');
$name = $file->getClientOriginalName();
$data[ 'movie_name' ] = $name;
$request->file('movie_name')->move(asset('movies'), $name);
return $name;
} else {
return false;
}
}
edited Nov 13 at 14:57
answered Nov 13 at 13:37
Peter Sowah
39719
39719
Still the same mistake.
– Gacho
Nov 13 at 13:49
Again, same thing.
– Gacho
Nov 13 at 15:44
In that case, it's a permissions thing then. Kindly crosscheck the permissions on the folder and if the server has rights to create files or not.
– Peter Sowah
Nov 14 at 11:27
add a comment |
Still the same mistake.
– Gacho
Nov 13 at 13:49
Again, same thing.
– Gacho
Nov 13 at 15:44
In that case, it's a permissions thing then. Kindly crosscheck the permissions on the folder and if the server has rights to create files or not.
– Peter Sowah
Nov 14 at 11:27
Still the same mistake.
– Gacho
Nov 13 at 13:49
Still the same mistake.
– Gacho
Nov 13 at 13:49
Again, same thing.
– Gacho
Nov 13 at 15:44
Again, same thing.
– Gacho
Nov 13 at 15:44
In that case, it's a permissions thing then. Kindly crosscheck the permissions on the folder and if the server has rights to create files or not.
– Peter Sowah
Nov 14 at 11:27
In that case, it's a permissions thing then. Kindly crosscheck the permissions on the folder and if the server has rights to create files or not.
– Peter Sowah
Nov 14 at 11:27
add a comment |
up vote
0
down vote
Try changing '/public/movies' permissions to 775.
sudo chmod -R 775 PATH/TO/DIRECTORY
I am using windows, and have full control over permissions.
– Gacho
Nov 13 at 15:45
add a comment |
up vote
0
down vote
Try changing '/public/movies' permissions to 775.
sudo chmod -R 775 PATH/TO/DIRECTORY
I am using windows, and have full control over permissions.
– Gacho
Nov 13 at 15:45
add a comment |
up vote
0
down vote
up vote
0
down vote
Try changing '/public/movies' permissions to 775.
sudo chmod -R 775 PATH/TO/DIRECTORY
Try changing '/public/movies' permissions to 775.
sudo chmod -R 775 PATH/TO/DIRECTORY
answered Nov 13 at 15:14
Felipe Pinheiro
1
1
I am using windows, and have full control over permissions.
– Gacho
Nov 13 at 15:45
add a comment |
I am using windows, and have full control over permissions.
– Gacho
Nov 13 at 15:45
I am using windows, and have full control over permissions.
– Gacho
Nov 13 at 15:45
I am using windows, and have full control over permissions.
– Gacho
Nov 13 at 15:45
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53281930%2fupload-movies-with-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
chmod ? stackoverflow.com/a/37266353/2693543
– Shobi
Nov 13 at 13:22
try to give permission to upload directory via chmod -R 777 uploadsdir
– Hemant Kumar
Nov 13 at 13:24
I have full control on the upload directory. It still shows the same mistake
– Gacho
Nov 13 at 13:27