How to display image after upload in php?

后端 未结 8 1952
無奈伤痛
無奈伤痛 2021-01-14 08:30

after uploading the image to a folder. how to display the image..

its my upload.php



        
相关标签:
8条回答
  • 2021-01-14 08:46

    I have tried your code and its working finely just need to change the line

    echo'<img src= "upload/".$img>'; 
    

    to

    echo'<img src="'.$img.'">';
    
    0 讨论(0)
  • 2021-01-14 08:49

    Try this:

    header('Content-Type: image/jpeg');
    readfile($imgPath);
    
    0 讨论(0)
  • 2021-01-14 08:54

    You need:

    echo '<img src="upload/'.$img.'"/>';

    0 讨论(0)
  • 2021-01-14 08:55

    You mixed up some quotes. It should be :

    $image = $_FILES["file"]["name"]; 
    $img = "upload/".$image;
    echo "<img src=\"upload/$img\">";
    
    0 讨论(0)
  • 2021-01-14 08:59

    Don't put $img in quotations. When you do it the output is simply $img, not upload/...

    echo < img src=" ' ,$img ,' ">;

    0 讨论(0)
  • 2021-01-14 09:05

    As you've already put "upload" in $img

    $img="upload/".$image;
    

    You don't need to put it in src anymore

    echo '<img src= "'.$img.'">';
    
    0 讨论(0)
提交回复
热议问题