简体   繁体   English

Getimagesize 在主机服务器中不起作用 - Hostinger

[英]Getimagesize is not working in host server - Hostinger

Code:代码:

$urli = 'https://st.quantrimang.com/photos/image/2020/02/20/Zalo-bat-tim-quanh-day-1.jpg';
$size = getimagesize($urli);
echo $urli.'.</br>Size:';
echo $size[0].'</br>';

If run in localhost => $size[0] ok - Run in server hostinger => $size[0] NULL Ps: allow_url_fopen is ON (check by: phpinfo(); Tks help@如果在 localhost => $size[0]运行 - 在服务器托管中运行 => $size[0] NULL Ps: allow_url_fopen is ON (检查方式: phpinfo(); Tks help@

Its because of the directory.因为目录。 The

'https://st.quantrimang.com/photos/image/2020/02/20/Zalo-bat-tim-quanh-day-1.jpg';

is the path for the HTML Wrapper.是 HTML 包装器的路径。 But PHP looks in the physical directory of the server (similar to your C:/xampp/htdocs/my_projects/st.quantrimang.com/photos ... on your Home-PC) On localhost both are (normally) the same.但是 PHP 在服务器的物理目录中查找(类似于您的家用 PC 上的 C:/xampp/htdocs/my_projects/st.quantrimang.com/photos ...) 在 localhost 上两者(通常)是相同的。 On live server the structure of the directory is more complex, because every customer has its own sub-directory.在实时服务器上,目录的结构更复杂,因为每个客户都有自己的子目录。 In the path to your physical directory on the live server are your accountnumber (and other things) also included.在实时服务器上您的物理目录的路径中还包括您的帐号(和其他东西)。 In short words: use简而言之:使用

$my_server_directory = $_SERVER['DOCUMENT_ROOT']; // could be a very long path

to get the server-root of your domain.获取域的服务器根目录。 Then然后

$urli = $my_server_directory.'/my_image_directory/image.jpg';
$size = getimagesize($urli);

should work.应该管用。

Btw: 'allow_url_fopen' is not relevant in this case.顺便说一句:'allow_url_fopen' 在这种情况下不相关。

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

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