Home Backend Development PHP Tutorial 用readfile函数读取图片时碰到的有关问题

用readfile函数读取图片时碰到的有关问题

Jun 13, 2016 am 10:00 AM
com quot readfile

用readfile函数读取图片时碰到的问题
我打算在一个页面显示图片,不是直接给出img的scr,而是由一个readfile函数输入,相当于由服务器读取图片再输出.
前台的页面如下:

用readfile函数读取图片时碰到的有关问题
用readfile函数读取图片时碰到的有关问题
...
用readfile函数读取图片时碰到的有关问题


后台的getobj1.php代码如下
header('Content-Type: image/jpeg');
readfile($_GET["path"]);
?>

现在问题是这样的:
图片都能显示正常,而且也的确是由服务器读取来的.(因为有些图片直接访问不到..GFW)
但是这些图片显示的时候是一个一个显示出来的.而不是像正常访问的时候那样是一起显示出来的.
这个有什么办法没,是图片所在服务器的问题还是PHP的机制问题?
请大家帮帮忙

------解决方案--------------------
应该是代码的问题 楼主可以从缓存这个角度去考虑 可以一次性读取 缓存起来 再输出 
ob_start
···//处理读出图片显示等操作
ob_flush();
flush();

------解决方案--------------------
这是正常的
因为,图片不在你的服务器上,只是从远程读过来,再传给客户端
你服务器,只是一个中转
既然多了一层中转,当然慢了,

有一个解决的办法
就是,
你可以建立一个缓存的目录
当你碰到一个请求时,查看服务器缓存中是否有,
如果没有,这个请求是第一次,就把远程的图片,存在服务器上
如果有,直接把本服务器的传给客户端

这样,每张图片,就只要中转一次了

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hongmeng native application random poetry Hongmeng native application random poetry Feb 19, 2024 pm 01:36 PM

To learn more about open source, please visit: 51CTO Hongmeng Developer Community https://ost.51cto.com Running environment DAYU200:4.0.10.16SDK: 4.0.10.15IDE: 4.0.600 1. To create an application, click File- >newFile->CreateProgect. Select template: [OpenHarmony] EmptyAbility: Fill in the project name, shici, application package name com.nut.shici, and application storage location XXX (no Chinese, special characters, or spaces). CompileSDK10, Model: Stage. Device

What is the difference between comcn and com What is the difference between comcn and com May 12, 2023 pm 04:08 PM

The difference between comcn and com: 1. There are differences between comcn and com in terms of meaning, but there is no difference in access speed; 2. comcn is an international domain name and is a global top-level domain name for use by commercial institutions, while cn is a Chinese company domain name , domestic commercial institutions, domestic domain names, only enterprises can register; 3. The search priority is that cn will search for .cn first. After finding the .cn server, the .cn server will then search for .com; 4. cn is provided by cnnic China Internet Center Management, com's management organization is abroad.

How to read the contents of a file using the io/ioutil.ReadFile function in golang How to read the contents of a file using the io/ioutil.ReadFile function in golang Nov 18, 2023 am 11:08 AM

How to use the io/ioutil.ReadFile function in golang to read the contents of a file. In golang, we can read the contents of a file through the ReadFile function in the io/ioutil package. The ReadFile function can read the entire file into memory at one time and return a byte slice ([]byte) as a representation of the file content. Here is a sample code that demonstrates how to use the ReadFile function to read the contents of a file: packag

php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 php提交表单通过后,弹出的对话框怎样在当前页弹出,该如何解决 Jun 13, 2016 am 10:23 AM

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

Complete list of PHP file download functions: analysis of file download examples of readfile, header, Content-Disposition and other functions Complete list of PHP file download functions: analysis of file download examples of readfile, header, Content-Disposition and other functions Nov 18, 2023 pm 03:26 PM

Complete list of PHP file download functions: File download example analysis of readfile, header, Content-Disposition and other functions. File download is one of the essential functions in Web applications, and PHP, as a widely used Web development language, provides many A function and method to implement file downloading. This article will introduce commonly used file download functions in PHP, including readfile, header, Content-Dispo

Solution to PHP Fatal error: Class 'COM' not found Solution to PHP Fatal error: Class 'COM' not found Jun 23, 2023 am 09:22 AM

PHP is a powerful programming language that is widely used in the development of web applications and desktop applications. However, when using PHP, you may encounter some errors and exceptions. This article will focus on the solution to "PHPFatalerror: Class'COM'notfound". Positioning Problem First, we need to understand the source of the error and the positioning problem. This error usually means that you are trying to use a COM extension in your code, but when loading the parser

图片消失怎么解决 图片消失怎么解决 Apr 07, 2024 pm 03:02 PM

图片消失如何解决先是图片文件上传$file=$_FILES['userfile'];  if(is_uploaded_file($file['tmp_name'])){$query=mysql_query("INSERT INTO gdb_banner(image_src ) VALUES ('images/{$file['name'

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题 不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没有关问题 Jun 13, 2016 am 10:15 AM

不用数据库来实现用户的简单的下载,代码如下,但是却不能下载,请高手找下原因,文件路劲什么的没问题。

See all articles