Mobile app version of vmapp.org
Login or Join
Yeniel560

: Write to an alias directory on Apache How do I enable writing via PHP to an alias directory. I have the following on my VirtualHost: <VirtualHost *:80> ServerName domain.com ServerAlias

@Yeniel560

Posted in: #Apache #Virtualhost

How do I enable writing via PHP to an alias directory.

I have the following on my VirtualHost:

<VirtualHost *:80>
ServerName domain.com
ServerAlias m.domain.com

...etc

AliasMatch ^(.*)/user/([a-zA-Z0-9_-]+)/images/(.*) "C:/Apache/webroot/user//images/"
<Directory "C:/Apache/webroot/user">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


So if I tried to view a file or an image from m.domain.com I can see it being fetched from the alias directory; however, when I try to write it fails.

for example if i tried something like <?php file_put_contents("user/sam/images/sample.png", $img); ?> it would fail.

Any suggestions or ideas is really appreciated.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Yeniel560

1 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

file_put_contents takes a file name, not webserver path. When you put in a relative path from the context of the webserver, it interprets it relative to $_SERVER['DOCUMENT_ROOT'].

To save into an aliased directory, you would need to specify the abolute path of that directory. There is a question about how to get the absolute directory of users public_html folders on StackOverflow

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme