Yulia Kovaleva
Yulia Kovaleva

Reputation: 31

Uploading files/creating folder outside webroot with mkdir and fopen over https connection

I am working on a web app that allows registered users to upload files to the folders outside the webroot. The basic workflow is as follow:

It looks like I can't even create a user's directory outside the webroot, let alone upload files into that directory. I'm using mkdir over the ssl connection. I have enabled allow_url_fopen and allow_url_include, but still no luck. I'm pretty sure openssl is enabled. Is there any way around this?

Thanks in advance, Yulia.

Upvotes: 3

Views: 1740

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270727

The directory outside the web root in which the new user directories are created must be writable by the web server user, in addition to creating the new user directories as 777.

Supposing the following structure:

root
  |->users
  |    |->new user1
  |    |->new user2
  |->www docroot

Set ownership on root/users to have the group of the web server user and make it writable. This assumes the directory is already owned by root, but if it's on a hosting service change to the existing owner username. Also assumes apache is the web server user.

chown root:apache /root/users
chmod 770 /root/users

Upvotes: 0

Related Questions