How to set read/write permissions in Apache on a W

2020-02-29 10:38发布

I am building a web page with Apache2.2, PHP5.2.2 on a Windows XP computer in a localhost configuration. I'm developing app/pages/submitProcessor.php to validate photo uploads from users. It validates file existance, size, mime type, drops unwanted characters, assigns a new file name, and uses move_uploaded_file() to store the file in app/uploads. I read in PHP - Question about uploading & uploaded image file that this photo storage file should be write only from app/pages/submitProcessor.php and it would be nice if it were read only from code within app/pages.

I've read a lot of info, and being pretty new to this, I still don't understand how to set read/write permissions in Windows XP in something resembling my configuration. I'm completely confused by 777, 775, 755, php.ini vs httpd.config and linux vs Windows. I'm also not comfortable with command line stuff, and would prefer to edit the appropriate file, if that is possible. How do I configure Apache so any file in app/uploads will not be executable, will write only from app/pages/submitProcessor.php, and read from app/pages/display or others in app/pages . . . or at least I'd like to get close to that. Not executable in the app/upload directory is pretty important to me.

2条回答
Summer. ? 凉城
2楼-- · 2020-02-29 11:12

If you are running Apache as a Service (the default setup for stand-alone & WAMP Apache installations), then that Apache Service is running under Windows' LocalSystem account.

This Windows account already has full read and write ('777') permissions on most local paths.

So when you read instructions to chmod 777 this, chmod 755 that, etc, ... you can ignore those parts of the instructions. Apache already can read-from and writeout-to those directories (unless it's a UNC path of a networked drive).

Setting File Permissions with chmod on Windows for Apache and PHP

I'm not 100% positive if that was the account on Windows XP (it is on Vista and up), but the behavior was the same.

查看更多
干净又极端
3楼-- · 2020-02-29 11:15

In Windows, access to directories/folders is set by right clicking the directory, and reading through the selections provided by the various tabs to set access and specific uses of the directory. Its not as fine-grained as CHMOD, but it was good enough for my purposes at the moment.

查看更多
登录 后发表回答