doupo5861 2014-03-10 16:02
浏览 26

从表单处理图像(图像不用作提交按钮)

I am trying to put an image link into a form (not as a submit button). I am having trouble extracting the image when I process the form.

Here is my php code for putting the image in a form...

$picture = "
    <div id='photo'>
        <input type='image' name='image' src='www.sampleimage.jpg'>
    </div>";

<div class='formData'>
    <form action='recToDb.php' method='post'>" . 
        $picture . 
        "<input type='submit' name='toDB'>
    </form>
</div>";

The image is uploaded as HTML and that part works fine. Once the user is satisfied, they can hit the submit button. At that point, I want to add the image (or the source of the image) to a database. For now, I am just trying to extract the image with this code...

if (isset($_POST['toDB']))
   {echo $_POST["image"];}

If I do var_dump($_POST), the image is not even in the array so I believe that the image is not going into the form, but I don't know exactly what my problem is.

Note that there are other things in the form that I did not display in the above code that I have no problem extracting.

  • 写回答

1条回答 默认 最新

  • dsasd12314 2014-03-10 16:40
    关注
     $picture = "
    <div id='photo'>
        <input type='image' name='image' src='www.sampleimage.jpg'>
    </div>";
    

    $picture should not pull the HTML, rather it should just contain the uploaded content.

    $picture = $_POST["image"];
    

    then you should be able to call $picture. As to my understanding, you are trying for:

    • After the image is uploaded, the image is displayed under the upload form.
    • The picture is uploaded to the server.
    • An entry is made in the database with the URL of the picture.

    EDIT: I feel I am not getting what you are trying to accomplish. Could you please link me to your whole code?
    Are other values being inserted into the database? If you are trying to accomplish just the image upload I suggest added another input.

    To display all errors that are not automatically thrown at you please add

    error_reporting(E_ALL);
    ini_set('display_errors', '1');
    

    after the code.

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line