- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在从 facebook 检索 facebook 相册图像。我使用 php 函数 getimagesize 计算图像大小。当 url 处于 http 模式时,此函数工作正常。当 facebook 使用 https 返回图像 url 时,getimagesize 给出错误.我如何使用 getimage size 计算具有 https 扩展名的图像的图像大小
最佳答案
您的 PHP 实例中没有安装 OpenSSL 扩展,因此 https://
包装器不可用。
Note: HTTPS is only supported when the openssl extension is enabled.
And :
To use PHP's OpenSSL support you must also compile PHP --with-openssl[=DIR] .
您需要使用 OpenSSL 扩展重新编译 PHP。
或者,按照其他人的建议,您可以将 https://
替换为 http://
,这对于 Facebook 图片应该同样有效 - 事实上,它可能会更快,并且肯定会更有效地利用带宽。
我会这样做:
$url = 'https://facebook.com/path/to/image.jpg';
$url = trim($url); // Get rid of any accidental whitespace
$parsed = parse_url($url); // analyse the URL
if (isset($parsed['scheme']) && strtolower($parsed['scheme']) == 'https') {
// If it is https, change it to http
$url = 'http://'.substr($url,8);
}
关于此的另一点是,将 $url
直接传递给 getimagesize()
可能不是您想要做的。您对图像所做的唯一事情不太可能是获取它的大小,您可能会在您的页面上显示它或以其他方式操纵它,如果是这种情况,您最终将不止一次下载它。
您可能应该将它下载到一个临时目录,然后处理它的本地副本。
关于php - getimagesize 和 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8518403/
直到最近,我一直在使用一些 PHP 将照片上传到网站。但突然间它开始触发各种错误消息。 我使用的表单会运行以下代码: $uploaddir = "../../user_content/photo/";
问题:getimagesize() 不适用于某些 URL,尤其是重定向的 URL。 我四处搜索并检查了 stackoverflow,但无济于事。 这是我在本地机器上看到的: var_dump(geti
我正在本地使用 wordpress,出于某种原因,当我从 page.php 调用 getimagesize() 来检索它不起作用的大小时。我收到警告: getimagesize(http://loca
尝试上传 .JPG 文件时出现以下错误。 Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in H:
我有以下脚本,它在我的本地服务器上使用 PHP 5.2.6 返回图像的高度和宽度,但在我使用 5.2.17 的共享主机帐户上没有。 ini_set('memory_limit', '32M'); li
我创建了一个函数,我正在使用此函数调整图像大小以使其适合作为 div 背景图像,我将 div 大小和图像路径发送给函数。当高度大于宽度时效果很好,但它不起作用当宽度大于高度时。这怎么可能? funct
我使用上传图像的 PHP 脚本,然后使用 PHP 的 getImageSize() 获取尺寸,然后根据图片方向(纵向或横向)对图像执行操作。 然而(PHP 版本 5.4.12)在一些 .jpg 文件上
我网站上的图片位于其他服务器上。我试图使用 php 的 getimagesize 获取图像的大小,但它不起作用。它给出了一个错误“getimagesize is not seekable”。我在其他服
height: '.$height; ?> 这会产生以下输出: width: height: 编辑,我收到以下警告: Warning:getimagesize(http://cor-forum.de
当我尝试 getimagesize($img) 而图像不存在时,我得到一个错误。我不想先检查文件是否存在,只是处理错误。 我不确定 try catch 是如何工作的,但我想做类似的事情: try: g
我在下面附上了包含这些细节的图片:宽度:3024px高度:4032px getimagesize() 函数返回相反的结果: $size = GetimageSize("test.jpg"); echo
PHP 手册说它最多返回 7 个元素。并说 0, 1 是宽度和高度,然后是图像类型和属性。然后继续举个例子 $size=getimagesize() 那么,它返回什么?一个包含 7 个元素的数组还是只
当我在作为共享服务器的托管公司中使用 getimagesize() 时,出现以下错误。 Message: getimagesize() [function.getimagesize]: URL fil
我有一些图像的信息存储在 MySQL 数据库中。图片本身存储在一个文件夹中,但数据库包含它们的 URL 以及其他相关数据。 我遇到了 PHP getimagesize,我想用它来填充 的 width=
出现错误。如何避免错误通知? 这是错误信息: Notice: getimagesize() [function.getimagesize]: Read error! in C:\xampp\h
我有这个功能 public static function upload($path_folder, $input_file_name) { $photo_file = $_FILES[$in
我正在使用 Valum's file uploader使用 AJAX 上传图像。这个脚本以我不完全理解的方式将文件提交到我的服务器,所以最好通过显示我的服务器端代码来解释: $pathToFile =
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: GetImageSize() not returning FALSE when it should 我目前有
我收到以下错误: getimagesize(https://static1.squarespace.com/static/570d03d02b8dde8b2642afca/570f74e87c65e4
我正在运行 getimagesize() 来确定上传的文件是否是有效图像及其 MIME 类型。我的网络应用程序的用户报告说,他的一些图像在上传后出现“无效文件类型”错误。所以我让他寄给我一些检查。 错
我是一名优秀的程序员,十分优秀!