Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permissions for files and directories on linux #19

Open
gloventRehan opened this issue Apr 13, 2017 · 2 comments
Open

Permissions for files and directories on linux #19

gloventRehan opened this issue Apr 13, 2017 · 2 comments

Comments

@gloventRehan
Copy link

gloventRehan commented Apr 13, 2017

PLEASE change chmod and mkdir permissions to 0750 (leading zero for octal representation) , it is currently as 750 so linux messes things up when you want to rmdir and all file permissions are also incorrect.

http://php.net/manual/en/function.chmod.php

(I wanted to branch and commit to that branch changes but couldn't ,wasted so much time on two missing 0, but further great library thanks)

@answerquest
Copy link

Hi @gloventRehan I'm not a programmer, want to use this in our local network. Running on apache/php server on my Ubuntu 16.04 laptop. Could you confirm that it's these two lines in php-uploader/src/class.uploader.php that need changing the 750 to 0750:

Line 150
if(!file_exists($options['uploadDir']) && !is_dir($options['uploadDir']) && mkdir($options['uploadDir'], 750, true)){

Line 154
if(!is_writable($options['uploadDir'])) @chmod($options['uploadDir'], 750);

Please also tell if it should be enclosed in quotes now or should be left without quotes.

@gloventRehan
Copy link
Author

That is correct so

Line 150 becomes:
if(!file_exists($options['uploadDir']) && !is_dir($options['uploadDir']) && mkdir($options['uploadDir'], 0750, true)){

Line 154 becomes:
if(!is_writable($options['uploadDir'])) chmod($options['uploadDir'], 0750);

Also note in Line 154 the @ sign is removed, the developers put this here to suppress any errors that this function generate. This is why it worked while I tested on windows and why it did not work and took many hours to find on the linux server. So I also highly recommend removing the @ sign before chmod, otherwise you will be left pulling your hair out to find out why your documents are not being uploaded. This way, it will warn you if it could not change the directory permissions and you can do so while testing before shipping your code to production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants