简体   繁体   中英

How to access files in public_html through the subdomain folder

I have a website called www.meagl.com ...In this, I created a sub-domain called m.meagl.com.

My public_html folder contains two folders called users and groups.

What I wish to do is access these folders through my sub-domain folders in php to get the images that I have stored in them. To do this, I add "../" to the existing file destinations in the sub-domain files wherever necessary. Example:to access users/sharvai/78.jpg , I wrote ../users/sharvai/78.jpg . But no images are being loaded onto my sub-domain.

Please help!!

Files outside of public_html are protected from being seen on the web. Many people use that feature as a security to their content. If you have a file on there that you want to show contents of though, you have to use the include('file.php'); or include_once('file.php'); or even require_once('file.php') in a public ally visible file. Aka a file you have in public_html has to be the one to call the higher up file. If I am understanding your question right, that is how it is supposed to be done.

UPDATED ANSWER:

I was initially thinking about this as if you were dealing with a .php file dependency. That was the wrong way to think about it. You are talking about images. Images, whether inline img tags or CSS backgrounds are served over http://. Therefore, you need to use a valid URL. Based on the information you have supplied, you want to use URLs like:

http://www.meagle.com/users/75.jpg

Shame on me for not realising this sooner.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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