从子域检查/上传图像到域文件夹

发布于 2024-10-02 06:48:23 字数 417 浏览 0 评论 0原文

我有域名 www.mysite.com 和子域 api1.mysite.com。 (在域中)有几个文件夹和文件夹“图像”。还有一个名为 api1 的文件夹,它是子域的文件夹。我不明白的是如何从子域中找到 domian 的文件夹“images”并在那里上传文件或检查它们是否存在。我正在使用 php。例如,

此行位于子域文件夹中的一个文件中,“images”文件夹位于上一级 - 在域文件夹中。

$dir_img_small = file_exists('images/users/small/i_'.$profile_id.'.jpg');

我尝试在图像之前使用 ../ 但它不起作用。请帮忙!

谢谢大家!我自己解决了。在图像前面添加../../www。注意到主目录中有一个快捷方式并且它有效。

I have domain www.mysite.com and subdomain api1.mysite.com. There (in domain) are several folders and folder "images". There also is a folder called api1 which is subdomain's folder. What I can't figure out, is how to locate from subdomain a domian's folder "images" and upload files there or check if they exist. I'm using php. e.g.

this line is located in one of the files in subdomain folder and "images" folder is one level up - in domain folder.

$dir_img_small = file_exists('images/users/small/i_'.$profile_id.'.jpg');

I tryed to use ../ before images but it didn't work. Please help!

THANK YOU EVERYONE! I SOLVED IT MY SELF. ADDED ../../www IN FRONT OF images. NOTICED A SHORTCUT IN HOME DIRECTORY AND IT WORKED.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

任谁 2024-10-09 06:48:23

也许您应该尝试提供目录的完整路径:

$root_path = "enter root path here/";
$dir_img_small = file_exists($root_path . 'images/users/small/i_'.$profile_id.'.jpg');

Perhaps you should try to provide the full path to the directory:

$root_path = "enter root path here/";
$dir_img_small = file_exists($root_path . 'images/users/small/i_'.$profile_id.'.jpg');
寄与心 2024-10-09 06:48:23

如果您使用 IIS,您可以在一个网站中定义一个“虚拟”文件夹,该文件夹指向服务器上某处的物理文件夹。

因此,您可以定义一个名为“images”的虚拟文件夹,并将其映射到与另一个站点的图像文件夹相同的物理文件夹。

If you are using IIS you could define a "virtual" folder in one website that points to a physical folder somewhere on the server.

So you could define a virtual folder called "images" and map it to a physical folder that is the same folder as the images folder of another site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文