简体   繁体   English

如何访问远程服务器上的PHP文件

[英]How to Access a PHP file on a remote server

Ok, so i have been using html for quite a while and am learning how to use php functions now. 好的,所以我已经使用html很长一段时间了,我正在学习如何使用PHP函数。 I have a domain and am using a hosting site to host my files, i have a php file that allows users to upload pictures to a specified file but i keep getting error messages. 我有一个域,并使用托管网站来托管我的文件,我有一个PHP文件,允许用户上传图片到指定的文件,但我不断收到错误消息。 the function works on my server, so i know it is correct, so i believe that this is probably a security issue with the site that i am using to host the file. 该功能在我的服务器上运行,所以我知道它是正确的,所以我认为这可能是我用来托管文件的网站的安全问题。 so i would like to use my server to handle the php and accept the upload. 所以我想用我的服务器来处理PHP并接受上传。 i tried just entering my url of the php file on my server in the #post line but i should have known it would not be that simple. 我试着在#post行中输入我的服务器上的php文件的URL,但我应该知道它不会那么简单。 i researched this and it looks like i need to set up a "listening page" php file and a variable that defines the url. 我研究了这个,看起来我需要设置一个“监听页面”php文件和一个定义url的变量。 since i am very new to this i was hoping someone could help me with specific instructions so that i can see the mechanics of this and understand it better. 因为我对此非常陌生,所以我希望有人可以帮我提供具体的指示,这样我就可以看到它的机制并更好地理解它。 this is my code: 这是我的代码:

<form enctype="multipart/form-data" action="upload.php" method="POST">
    Please choose a file: <input name="uploaded" type="file" /><br/>
    &#60;input type="submit" value="Upload" />`

once the user submits the file it is handled by the following code 一旦用户提交文件,它将由以下代码处理

$target = "upload/"; 
$target = $target . basename( $_FILES['uploaded']['name']) ; 
$ok=1; 
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) 
{
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
} 
else {
    echo "Sorry, there was a problem uploading your file.";
}

if ($uploaded_size > 10000)
{
    echo "Your file is too large.<br>"; 
    $ok=0;
}

if ($uploaded_type =="text/php")
{
    echo "No PHP files<br>";
    $ok=0;
} 

so how to i get the form to call this function on my server? 那么如何让表单在我的服务器上调用此函数? http://www.server-name/folder/upload.php HTTP://www.server-name/folder/upload.php

This is caused because your server is not allowing you to upload external images to your server. 这是因为您的服务器不允许您将外部图像上传到服务器。

Change server's image upload directory permission to 777 . 将服务器的图像上载目录权限更改为777

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

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