can someone explain this to me please!🤲 | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

can someone explain this to me please!🤲

in php we can use the built-in include construct to include other documents in a page...if so then i tried to do this and i get the error i dont understand what went wrong include "http://127.0.0.1:8000/imgs/profile.png" i was doing this in my computer locally and i run two separate local servers at different ports. i tried to access an image from one server into another is that possible??

7th Nov 2020, 4:57 AM
Godson Lyimo
Godson Lyimo - avatar
4 Réponses
+ 3
It looks like you want a PHP script to respond with a viewable PNG image. The following should work better. Make sure you don't have even a single character printed before this runs. A single line break or space character will make the header call fail and the image's data invalid. $file = 'http://127.0.0.1:8000/imgs/profile.png'; header('Content-Type: image/png'); // tell the browser that this can be shown instead of treating it like HTML. echo file_get_contents($file);
7th Nov 2020, 10:12 PM
Josh Greig
Josh Greig - avatar
+ 1
profile.png file seems to be an image not text file.
7th Nov 2020, 10:08 PM
Rafał Kołpak
Rafał Kołpak - avatar
+ 1
Rafał Kołpak yes its an image, but an image is a file, is it possible to access it?
8th Nov 2020, 8:39 AM
Godson Lyimo
Godson Lyimo - avatar
0
Josh Greig thanks josh it worked!
8th Nov 2020, 8:40 AM
Godson Lyimo
Godson Lyimo - avatar