I have a project, there are 3700 products in the database.
Every product will have its images folders to hold its images. To make things simple, these images folders are named the same as the products code.
These images/images folders could be ftpped to the server. Or they could be created automatically and uploaded to the server throw web pages (php programming).
When these images/images folders ftpped to the server, the owner is the ftp user, and the permission is set as rw-r--r-- (my default ftp set up).
When these images/images folders created by the web page, the owner is www, and the premission could be rw-r--r-- or others (according to the programming codes).
Now here comes the problem.
When I delete the product record from the database through the web access (php) page, I wanted the programming can also delete its images/images folders.
if these images are uploaded throw web interface, then the owner is www, so the programming can do anything with these images (becasue it owns the images), including delete.
But if these images are ftpped to the server, then the owner is the ftp user, not the www. then the programming page cannot delete these images, due to it is not the owner, and the files permission is rw-r--r--. So in this case, the programming pages doesn't have permission to delete these images/images folders.
How to solve it?
1) not ftp images to the server, all the images/images folders are created and uploaded through web access page (php programming). so php programming will own these images and can delete it as will.
But for the project like these, the merchant may want to create thousdands images/images folder (named them right) at his desktop computer, and then ftp it to the server hundreds folders/images at once. If we force them to use the web access (php programming) page to upload all these folders, it will be very slow and not effcient.
2) set up the ftp files default permission to 666 or 777 or something like that, so the web page can have the permission to delete these ftpped files. But it is not good security practice, specially for shared hosting.
Is there a better solution?
3) Could I somehow set up the ftp and make it that all the files uploaded to other folders are still rw-r--r--. But the files uploaded to certain folder and its sub-folders such as productImages and its subfolders will be with permission rw-rw-rw.