0
votes

So I created a couple of directories and files with FTP, thus the owner is the username I use to login to the server. Now I'd like to allow users of the website to upload images to those directories. Unfortunately for the website to store images, it should be owned by Apache. How can I fix this? I've been reading around on this but can't directly find an answer.

I don't have SSH, so I guess all command-line-things are not applicable for me.

Edit

I tried to then make the folders again using apache, but now ofcourse I can't write any files using ftp into those directories.

2

2 Answers

1
votes

Provided that at least the one directory is writeable by the apache user (lets call this directory 'writeabledir', it may be your root dir '/'), you must delete the folders you created via ftp and create a php script to create the directories you need. If for example you want a directory called users and inside it another directory called upload

Create file makedirs.php on your server.

<?php
  $oldumask = umask(0); 
  mkdir("writeabledir/users/upload",0777,true); // or even 01777 so you get the sticky bit set 
  umask($oldumask); 
?>

Now run your makedirs.php once, by calling your.serv.er/makedirs.php on your browser

EDIT:

If you don't want to delete and recreate your directories,you could always try to change file permissions from ftp.

For exampe with FileZilla, just right click on the desired folder and set permissions to 777. If your ftp user does not have permission to do this, then there is no other way, except from asking an administrator to do this for you.

EDIT2:

Added umask to ensure that folders created by apache are writeable by everyone. (taken from http://us3.php.net/manual/en/function.mkdir.php#1207 )

-1
votes

Friend looks I work in php, some versions change the way of solution, however the most common is already that you want to store it would be necessary to create a database and import it to esu code that also serves to some images you want to come place, plus the wisest thing to do and you create a database with the fields necessary for its realization, import, put in a file directory of your schedule, you also advise using aptana Studio 3 greatly facilitates the creation of codes among many things and low xampp it already comes with apache integrated in one place will help you a lot any questions on installation just look at youtube he will describe