Ask an image display question. I want to create a php page with the image search function. the url contains id = XX, and php uses get to get the value of id. If you find an image with the same file name and ID, it will be displayed. if you do not find the image, it will display upload.gif ". I am a newbie. I wrote a paragraph referring to the online example, but I cannot display the picture. Please give pointers.
The code is as follows:
Reply to discussion (solution)
Read the image in readfile and read the binary data.
Echo '';
You can display images on the webpage.
$ Filename = "/'Your id'.gif ";
Why quotation marks?
$ Filename = "/$id.gif ";
In addition, remove echo and BOM header.
What's more, it is unlikely that you put the image on the root of the file system?
I want to create a php page with the image search function. the url contains id = XX, and php uses get to get the id value. If you find an image with the same file name and ID, it will be displayed. if you do not find the image, it will display upload.gif ". I am a newbie. I wrote a paragraph referring to the online example, but I cannot display the picture. Please give pointers.
The code is as follows:
I wrote a demo.
$id = isset($_GET['id'])? $_GET['id'] : 0;$filename = intval($id).".gif";if(file_exists($filename)){ echo '';}else{ echo '';}
Thank you very much. The problem has been solved successfully. The original mistake is so outrageous, shame. By the way, $ id = isset ($ _ GET ['id'])? $ _ GET ['id']: 0; what does it mean?
Thank you very much. The problem has been solved successfully. The original mistake is so outrageous, shame. By the way, $ id = isset ($ _ GET ['id'])? $ _ GET ['id']: 0; what does it mean?
Isset check whether the variable is set
If set, run the "?" operation? If not, run the following command:
Thank you very much. The problem has been solved successfully. The original mistake is so outrageous, shame. By the way, $ id = isset ($ _ GET ['id'])? $ _ GET ['id']: 0; what does it mean?
Isset check whether the variable is set
If set, run the "?" operation? If not, run the following command:
Thank you for your answers! Thank you!