PHP access to FTP users pictures


#1

Let me start by saying I’m SUPER new to this. I’m trying to use PHP to make a gallery page. All of the pictures are in an FTP user’s directory though. When I try to load my page I get the following error (I did change the names and directories):

Warning: opendir(/home/ftp_user/test/pictures/2016/09/23/): failed to open dir: Permission denied in /home/main_account_name/url.net/gallery_test/debug.php on line 174

I don’t have an .htaccess file and I haven’t modified any of the dreamhost php files. I did try making an .htaccess file but I didn’t know what to put in it or even where to place it. in my main_account_user’s root or in the root of the ftp_user’s root.

Can I do what I’m trying to do? How can I do what I’m trying to do?

The reason I’m doing it this way is because the I don’t want the account uploading the pictures to have access to anything but the pictures they’re uploading.

Thank you in advance!


#2

If this is on shared hosting or VPS, no you can’t do what you’re try to do. See: https://help.dreamhost.com/hc/en-us/articles/215562847-One-user-per-domain-policy for more info.

On a Dedicated Server, yes but you need to turn off dreamhost management and make some manual changes.

(Historically there was a time this could be done, eventually disabled because it was exploitable.)


#3

Thank you LakeRat, you definitely saved me a lot of time fiddling around. I think I’ll have to use PHP to FTP into the user’s directory then. That’s might be the most secure way I can think of to implement this.


#4

hint: add hosting to the ftpusers directory as a sub-domain, say images.yourdomain.com. Then you can use them in place without having to move them or play other games.