doumianfeng6979 2017-11-15 13:22
浏览 61

如何将图像保存到会话变量PHP中

FILE 1:

$_SESSION['imguserF'] =  $_FILES['imguser'];

FILE 2:

<p>Photo: </p><input id=\"imgrace\" type=\"file\" name=\"imguser\" />

When I create a session variable, file 2 opens. I want that when file2 be open, the image saved into session variable be selected into the input.

How can I get that value and insert it into the input?

  • 写回答

1条回答 默认 最新

  • dongmoxin7111 2017-11-15 13:54
    关注

    I will try to break it down as much as i can:

    First we have your form:

    Php can not read elements like javascript or css can so you need to include what you want inside form. In form you must define the method you are going to use (post,get) and the action which is your php file. I provide you a sample form to help you understand

    <form method="post" action="test2.php">
        <p>Photo: </p><input id="imgrace" type="file" name="imguser"/>
        <input type="submit" id="imguser" name="imguser2"/>
    </form>
    

    After that we move to php section:

    In php file i need to receive what i am sending. The method that i set in html must be the one that receives in php and of course the same file name. I present you a sample of php file:

    $data=$_POST['imguser'];
    echo "<img src='/$data' />";
    

    What this 2 files are doing is simple. I upload an image from the html page, i capture it and display it in php page. My variable $data has all the info i need (the image name) to display the image and except of display i can simple store it into a DB. Also you need to submit your form. Php is not real-time like ajax calls or javascript functions so needs to "refresh".

    评论

报告相同问题?

悬赏问题

  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答