如何通过PHP上传后永久显示图像? [英] how to display image permanently after upload via php ?

查看:46
本文介绍了如何通过PHP上传后永久显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1→我有PHP代码完美地上传图像并将图像保存到目录但图像显示临时!我想永久地显示它...每当我想要更改图像时它会改变图像并显示上传的图像



这里是代码

form.php



1-> I have php code which perfectly woks its upload the image and save the image to directory but the image is display temporary ! i want to display it permanently ... and whenever i want to change the image it will change the image and display uploaded image

here are the code
form.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<form action="process.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file" /><br />
    <input type="submit" name="submit" />
</form>

<?php

    if(isset($_GET["img"]))

    {

        $n=$_GET["img"];

        echo "<img src='photos/".$n."'>";
    }
?>
</body>
</html>







现在上传代码



process.php






now uploading code

process.php

<?php


    $fn=$_FILES["file"]["name"];
    if(!empty($fn))
    {
        $res = move_uploaded_file($_FILES["file"]["tmp_name"],"photos/".$fn);
        if($res)
        {
            header("location:form.php?img=".$fn);
        }
    }
?>







this code perfectly work in my local host just create photos folder also where uploaded image will save.....

plzz help me guyz how to display the image permanently and if i want to display two image at the same time at different image how to display it !! plzz use this code and make it as i want it plzzz guyzz help me

thank you

推荐答案

_GET [img]))

{

< span class =code-summarycomment>
_GET["img"])) {


n =
n=


_GET [ img];

echo < span class =code-summarycomment> < img src =' photos /\".
_GET["img"]; echo "<img src='photos/".


这篇关于如何通过PHP上传后永久显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆