How can I read images in a folder?

Source: Internet
Author: User
In this way, an image can be displayed, but what should I do if I want to display all the images in the img folder? I cannot change it to $ url & #039; upload & #039; what should I do? {Code...} can display an image, but what should I do if I want to display all the images in the img folder? I cannot change it to $ url = 'upload/'. what should I do?

Header ("Content-Type: image/jpeg; text/html; charset = utf-8" encode your url0000'1.jpg '; $ img = file_get_contents ($ url, true); echo $ img;

Reply content:

In this way, an image can be displayed, but what should I do if I want to display all the images in the img folder? I cannot change it to $ url = 'upload/'. what should I do?

Header ("Content-Type: image/jpeg; text/html; charset = utf-8" encode your url0000'1.jpg '; $ img = file_get_contents ($ url, true); echo $ img;

There are many methods. examples are as follows:

$ Dir = "upload/"; // if (is_dir ($ dir) {if ($ dh = opendir ($ dir) directory to be obtained )) {while ($ file = readdir ($ dh ))! = False) {$ filePath = $ dir. $ file; echo "" ;}closedir ($ dh );}}

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.