简体   繁体   English

如何显示子域中域文件夹中的图像

[英]How to display image from domain folder in subdomain

I need help on how to display image from a folder on a domain directory to a subdomain. 我需要有关如何将图像从域目录上的文件夹显示到子域的帮助。 I am on m.domain.com/user but i want to display user images on www.domain.com/user so i don't have to make duplicate. 我在m.domain.com/user上,但我想在www.domain.com/user上显示用户图像,因此我不必重复。 The folder structure is like this: 文件夹结构如下:

  • home
  • public_html/user 的public_html /用户
  • public_html/m/user 的public_html /米/用户

This is the code on www.domain.com/user.php 这是www.domain.com/user.php上的代码

$profile_pic = '<img src="user/'.$u.'/'.$avatar.'" alt="'.$u.'">';

What am I to write in m.domain.com/user.php to access images on this same directory at www.domain.com/user? 我要在m.domain.com/user.php中写些什么来访问www.domain.com/user上同一目录中的图像?

您必须为图片使用绝对网址

$profile_pic = '<img src="http://example.com/user/'.$u.'/'.$avatar.'" alt="'.$u.'">';

src属性中,只需编写src="http://www.domain.com/users/'.$u etcetera。

or just step outside the current directory into the parent directory using 或者只是使用以下命令将当前目录移出父目录

../ in ur path as many times as its neeeded for example: ../在您的路径中的次数是其需要的次数,例如:

<?php

include "../Global_Assets/Includes/Subscription_Widget/index.php";
?>

providing they are in the same directory on the web server otherwise you would need to use absolute paths IE: http://www.example.com/ 如果它们位于Web服务器上的同一目录中,否则您将需要使用绝对路径IE: http : //www.example.com/

Can you please paste the string after 'echo' the $profile_pic? 您能否将字符串“ echo”粘贴到$ profile_pic之后? If I'm not mistaken you need a leading slash. 如果我没记错的话,你需要一个斜杠。

$profile_pic = '<img src="/users/'.$u.'/'.$avatar.'" alt="'.$u.'">';

And I think you also missing a trailing "s" of users. 而且我认为您也错过了尾随的“ s”用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM