php.ini中的allow_url_fopen = 1无法正常工作

时间:2017-09-12 15:31:21

标签: php cpanel

我正在尝试从我的iPhone设备上传文件。我上传文件的php脚本是:

<?php
    $uploaddir = 'http://xxxxxxx.com/UploadImageInServer/'; 
    $file = basename($_FILES['userfile']['name']); 
    $uploadfile = $uploaddir . $file; 
    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
        echo "Received file: $file"; 
    }
?>

但是我在目录error_log文件中收到了这些警告:

PHP Warning:  move_uploaded_file(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/xxxx/public_html/UploadImageInServer/imageUpload.php on line 27
PHP Warning:  move_uploaded_file(http://xxxx.com/UploadImageInServer/a.jpg): failed to open stream: no suitable wrapper could be found in /home/xxxx/public_html/UploadImageInServer/imageUpload.php on line 27
PHP Warning:  move_uploaded_file(): Unable to move '/tmp/phpKlBQI6' to 'http://xxxx.com/UploadImageInServer/a.jpg' in /home/xxxx/public_html/UploadImageInServer/imageUpload.php on line 27

第27行是这样的:if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))

所以,谷歌之后,我发现我需要在allow_url_fopen = 1中设置php.ini

通过以下脚本在我的远程目录中使用test.php文件,我尝试找出php.ini文件的位置及其当前状态。哪个给我这个:

echo php_ini_loaded_file(); 

if( ini_get('allow_url_fopen') ) {
    echo "Yes";
} else {
    echo "No";
}

echo/opt/cpanel/ea-php70/root/etc/php.ini&amp; No

现在我将设置更改为显示我的隐藏文件,并在php.ini文件夹中找不到etc文件。所以我创建了一个新代码并将此代码放在allow_url_fopen = 1并从模拟器构建我的应用程序。

但仍然得到同样的警告。我还将我的php.ini文件移动到我的根目录中,在构建之后我仍然会收到相同的警告。那么我在这里做错了什么?如果您有解决方案,请与我分享。非常感谢提前。

祝你有个愉快的一天。 :)

P.S:我的php版本是7.0

0 个答案:

没有答案