Tutorial: Use the fpassthru () function of PHP to show detailed pictures and how to deal with them-php Tutorial

Source: Internet
Author: User
Tags smarty template zend framework
Tutorial: the fpassthru () function of PHP shows an image to explain how to learn PHP. it may not be asked, which means the following: wamp environment, zend Framework + smarty Template 1. & lt; imgsrc & quot; controlleraction parameter 1 parameter value & quot; & gt; is it feasible to use fpassthru to pass an image in the action to display it? How to write? 2. Tutorial: Use the fpassthru () function of PHP to show pictures
New PHP may not be asked, which is probably like this:

Wamp environment, zend Framework + smarty Template

1. Then, in the action, use fpassthru to pass an image to show whether it is feasible? How to write?

2. Can I use fpassthru to transmit images to the foreground without using the img tag?

------ Solution --------------------
... Action {
// 1 you can directly output the image content, for example, fpassthru you mentioned:
PHP code
// Open the file $ name = 'in binary format '. /img/OK .png '$ fp = fopen ($ name, 'RB'); // send the appropriate header ("Content-Type: image/png "); header ("Content-Length :". filesize ($ name); // send the image and terminate the script fpassthru ($ fp); exit;
------ Solution --------------------
Rewrite_module can be used for anti-Leech protection in apache. using these output file headers can only increase the server load.

Http://sealbird.iteye.com/blog/976891
------ Solution --------------------
Discussion

I also found it yesterday, but I tried it. I don't know where the problem is.

The following 'RB' should be a parameter. I have not found this parameter in the manual. so I 'd like to ask a question to see if there is more useful information.

------ Solution --------------------
Comment out the header ("Content-Length:". filesize ($ imgpath ));

Header ("Content-Type: image/jpg ");
Only image data streams

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.