Search code examples
phpapacheopen-basedir

Saving files to another DocumentRoot using PHP


I have a site that generates some image files. Instead of saving to within the site's DocumentRoot like \home\mysite\public_html\photos, I want to save to another user's directory like \home\anothersite\public_html\photos. The reason for doing this is to facilitate a move of all photos to its own dedicated server just for serving images.

Is there a way for PHP to save a file to another user's directory? I am thinking of using rename() and disabling open_basedir. Or should I use ftp_fput()?


Update

When I try this (which involves mkdir() to create new directories), I get the error:

mkdir() [function.mkdir]: Permission denied

Did I miss out on some permission settings?


Solution

  • You can save it exactly the same way as you are doing now / in the current directory. PHP does not care about the document root of the web-server

    Answer by Jeron.