简体   繁体   English

PHP将文件上传到路径作为完整域地址

[英]PHP upload files to path as full domain address

I am using PHP to upload files onto my web server from a subdomain. 我正在使用PHP从子域将文件上传到Web服务器。

my subdomain is admin.domain.com which is located in the directory admin before the public_html directory (i am using cPanel) 我的子域是admin.domain.com ,它位于public_html目录之前的admin目录中(我正在使用cPanel)

i want to be able to upload files into the admin directory which is up a level from the public_html directory from admin.domain.com and also from just domain.com 我希望能够将文件上传到admin目录中,该目录是从admin.domain.com以及从domain.com到public_html目录的一个更高级别

what path names will i need to use to do this? 我需要使用什么路径名来做到这一点?

If I understood correctly, your files are in the same server, in the same file structure, just being seen through differents domains. 如果我正确理解,则您的文件位于同一服务器中,处于同一文件结构中,只是通过不同的域即可看到。 If yes, then what you need to check is: 如果是,那么您需要检查的是:

1 - The path for the admin directoy, for example: F:/wamp/www/php/super-variables/test-$_server.php 1-管理目录的路径,例如:F:/ wamp / www / php / super-variables / test-$ _ server.php

For that, you can throw a php file with <?php echo ["SCRIPT_FILENAME"]; ?> 为此,您可以使用<?php echo ["SCRIPT_FILENAME"]; ?>抛出一个php文件<?php echo ["SCRIPT_FILENAME"]; ?> <?php echo ["SCRIPT_FILENAME"]; ?> in the folder. <?php echo ["SCRIPT_FILENAME"]; ?>在文件夹中。 It will return the path for that folder. 它将返回该文件夹的路径。

2 - Check if you have permission to upload files in that folder: 2-检查您是否有权在该文件夹中上传文件:

For that, It will depend on how much permission you have in your server. 为此,这将取决于您在服务器中拥有多少权限。 I use the Filezilla FTP to do that. 我使用Filezilla FTP来做到这一点。

$uploadPath = realpath( __DIR__ . '/..' );

在变量中设置路径,并在每次上传任何文件时使用move_uploaded_file()将文件移至所需位置。

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

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