Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php和HTML将图像上载到cPanel 403错误_Php_Image_Permissions_Upload_Cpanel - Fatal编程技术网

使用php和HTML将图像上载到cPanel 403错误

使用php和HTML将图像上载到cPanel 403错误,php,image,permissions,upload,cpanel,Php,Image,Permissions,Upload,Cpanel,我正在尝试将图像上载到主机服务器,但我收到了一个403错误,我没有这样做的权限。我已尝试使用chmod将对脚本和包含的站点文件夹的权限提升到777,但仍然得到相同的403错误 filename = basename($_FILES['userfile']['name']); $target_dir = "/upload/"; $target_file = $target_dir . $filename; $imageFileType = s

我正在尝试将图像上载到主机服务器,但我收到了一个
403错误
,我没有这样做的权限。我已尝试使用chmod将对脚本和包含的站点文件夹的权限提升到777,但仍然得到相同的
403错误

    filename = basename($_FILES['userfile']['name']);
        $target_dir = "/upload/";
        $target_file = $target_dir . $filename;
        $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
        $extensions_arr = array("jpg","jpeg","png","gif");
        $response = null;
        if( in_array($imageFileType,$extensions_arr) ){    
          move_uploaded_file($_FILES['userfile']['tmp_name'],$target_dir.$filename);
        }
注意:我的站点存储在public_html文件夹中 下面是我得到的错误

下面是用于上传图像的php代码,它只是一个基本的上传脚本,在本地运行良好,但当我托管时,它抛出一个
403错误

    filename = basename($_FILES['userfile']['name']);
        $target_dir = "/upload/";
        $target_file = $target_dir . $filename;
        $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
        $extensions_arr = array("jpg","jpeg","png","gif");
        $response = null;
        if( in_array($imageFileType,$extensions_arr) ){    
          move_uploaded_file($_FILES['userfile']['tmp_name'],$target_dir.$filename);
        }
有人建议,这可能是因为我的php文件上传选项是关闭的,只是检查它们是否打开


“/upload/”
更改为
“upload/”
我尝试过,mate甚至尝试使用根目录的整个链接检查图像大小。使用
var\u dump(is\u dir($target\u dir))
检查目标路径是否存在。Apache的MOD\u安全性阻止包含任何HTML代码的表单提交。尝试在不使用HTML代码的情况下上载图像。将
“/upload/”
更改为
“upload/”
我尝试过,甚至尝试使用根目录的整个链接检查图像大小。使用
var\u dump(is\u dir($target\u dir))检查目标路径是否存在
.Apache的MOD_安全块形成包含任何HTML代码的提交。尝试上载没有HTML代码的图像。