johanWP's avatar

File permissions on Windows

I'm using L5.1 on Windows 10/Apache as my server, and I want to upload a file to /public/img/userImages , to do that I manually created the folder userImages and used this in my UserController:

       if($request->image)
       {
           $imageName = $request->username . '.' .   $request->file('image')->getClientOriginalExtension();
           $request->file('image')->move(base_path() . '/public/img/userImages/', $imageName);
       }
       $user = User::findOrFail($id);
       $user->update($request->all());
       flash('User updated', 'success');
       return redirect('users')

The image is uploaded successfully but it doesn't show in the browser and I have to manually change Windows permissions to open it in file explorer. After I change permissions to Everyone, then it's shown correctly in browser. It happens to every file uploaded. That's something I'd expect from Linux not Windows.

Any suggestions?

0 likes
3 replies
d3xt3r's avatar

That's something I'd expect from Linux not Windows.

May be windows is getting smarter (stricter) after all. May be try setting a recursive permission on /public/img/userImages. Cannot check this, no windows m/c

johanWP's avatar
johanWP
OP
Best Answer
Level 2

userImage folder was marked as read only, I unchecked that on Windows Explorer and now files are showing correctly in the browser.

1 like
Stretsh's avatar

Check to see which user is running Apache and make sure that this user has permissions on your userImages folder and it's sub folders. Right click -> Properties -> Security Tab -> Advanced.

Please or to participate in this conversation.