douyiqi9640 2013-09-30 23:31
浏览 22
已采纳

将文件上载到Apache别名目录和子目录

I have two virtual hosts on my server. One "web" and one "mobile". I can view files from the "web" under the directory "users" normally but I cannot upload or create directories under it?!!

for example:

<img src='http://m.domain.com/users/imgs/sample.png' /> this is viewable 

//this is not possible
<?php 
  mkdir("users/newDir"); //fails

  $img = file_get_contents("http://images.devshed.com/fds/belts/ds_forums.gif");
  $file = "users/newDir/sample.gif";
  file_put_contents($file, $img); //fails

  $img = file_get_contents("http://images.devshed.com/fds/belts/ds_forums.gif");
  $file = "users/sample.gif";
  file_put_contents($file, $img); //fails

?> 

I have the following under my mobile virtual to point to the files on my "web":

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

 DocumentRoot "C:/Apache/mobileroot"
 <Directory "C:/Apache/mobileroot">
     Options FollowSymLinks
     AllowOverride None
     Order allow,deny
     Allow from all
 </Directory>

 Alias /users/ "C:/Apache/webroot/users/"
 <Directory "C:/Apache/webroot/users/">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
 </Directory>
</VirtualHost>
  • 写回答

1条回答 默认 最新

  • duansanzi5265 2013-10-05 20:18
    关注

    To answer my own question if someone stumbled the same issue in the future.

    Under the mobile directory all references to write had to switch them to absolute path the case of mkdir("users/newDir");

    So on the "web" directory it stays the same but on the "mobile" directory I changed all write actions to use absolute path like:

    mkdir("C:/Apache/webroot/users/newDir");

    This forces the new directory "newDir" to be created on the "web" not on the "mobile" directory on the server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来