arrays - unable to show image from external hd php -


I am new to programming and am now learning php. I have installed the xim and have written a bit code. I have some pictures on my external HD and I want to show some pictures. The problem is that I can get a list of the paths of my images with this code:

  echo " gt; body ; $ External DIR = "X: \ map \ maps \ more \" "$ total = count (array_diff (scanner ($ external diameter), array (". "," .. "))); $ Dirs = array_diff ( Scandor ($ External Dior), Array (".", "..")) Foreign Currency ($ dirs $$) {if (! Is_dir ($ external DIR. $ D)) {echo $ d "& lt;  

But if I want to show it as an image, then I can not show the image. I tried to do it in foreach:

  if (! Is_dir ($ external. $ D)) {$ file = $ outerhDir $ D; Echo 'img src = "'. $ External Direct $ d '' Gt; & Lt; Br> '; Echo '' & lt; Img src = '". $ External Diaries"' \\ '. $ D. "' Alt = '" $ D.' '& gt; & lt; br & gt; "}}  

But none of them works. I also tried the header and file_get_content:

  if (! Is_dir ($ ('content-type: image / JPEG'); header ('content-length:'. Filesystems ( $ File)); $ image = file_get_contents ($) = $ External Dior. $ D; '$ File'); echo $ image. "

Even A simple HTML code will not work! Like this:

  echo ' ';  

BUTTTT !! When I store an image it will work as my PHP file in the same folder! E:

  echo  

but I For technical reasons, for simple reasons, because I want to keep all my files in the same folder as a PHP file and I do not want to learn programming to avoid problems or problems with my code.

Hopefully I will better define my problem and hope that one of you and / or girls I know e solution to help me.

If your image files are not in a folder That's set up accessible from the web server, so easy you can not display them on a web page. Put them in a web directory to use them.

It is possible to write a PHP script that proxies image files (such as you are trying with file_get_contents () ), but to do so Requires a separate PHP file, and unless it is absolutely not necessary, it is best left, because it can easily introduce security vulnerabilities, and perform poorly if you want to do it , Though:

  • Image of an image Link the PHP script to the location, and pass it to the identifier for the image as a parameter (e.g., ).
  • In that script, use that identifier to send the appropriate content-type, then use readfile () to output the image (this echo File_get_contents (...) , but in some circumstances it performs more concise and better.)
  • Ensure the full parameter on that script File can not be manipulated to make available to you Received such was not intended, including diplomacy ? Image = .. / .. / False / File .

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -