doujing1156 2018-05-01 14:07
浏览 74

错误414:提交的URI太大了! 我该如何解决?

I am storing images into a database that are being uploaded by users using this form.

profiletest.php

<form action="profiletest.php" method="POST" enctype="multipart/form-data">
        Select image to upload:
        <input type="file" name="image"/>
        <input type="submit" name="submit" value="Submit"/>
    </form>

Here is the code that stores the images into the database

<?php
   if (isset($_POST['submit']))
   {
       if (getimagesize($_FILES['image']['tmp_name'])== FALSE)
       {
           echo "Please select an image.";
       }
       else
       {
           $name= addslashes($_FILES['image']['name']);
           $image= base64_encode(file_get_contents(addslashes($_FILES['image']['tmp_name'])));
           saveimage($name,$image);

       }
   }

   function saveimage($name, $image)
   {
       $conn = mysqli_connect("localhost","root","","loginsystem"); 

       $sql="insert into testimage(name,image) values('$name', '$image')";
       $query=mysqli_query($conn,$sql);
       if ($query)
       {
           echo "<br/>Image Uploaded.";
       }
       else
       {
           echo "<br/>Image not uploaded";
       }
   }

?>

I then display those images in the exploretest.php page

exploretest.php

<?php
    display();

     function display(){
       $conn = mysqli_connect("localhost","root","","loginsystem");
        $sql="select * from testimage";
         $query=mysqli_query($conn, $sql);
         $num=mysqli_num_rows($query);
         for ($i=0; $i < $num; $i++) {
             $result=mysqli_fetch_array($query);
             $img=$result['image'];
             echo '<img  class="exploreimg" src="data:image;base64, '.$img.'" style="max-height:300px;max-width:300px; margin-left:50px; margin-right:50px; padding-bottom:20px; padding-top:30px;">';

            echo '<a href="' . $img . '" src="data:image;base64, '.$img.'" "download="imageName"><img src="img/downloadbutton.png" alt="Download" style="max-height:50px; max-width: 100px; float: center; line-height: 10;"/></a>';

         }
     }


?>

I use this piece of code to generate a download button for the user to download the chosen image

echo '<a href="' . $img . '" src="data:image;base64, '.$img.'" "download="imageName"><img src="img/downloadbutton.png" alt="Download" style="max-height:50px; max-width: 100px; float: center; line-height: 10;"/></a>';

Everytime I press one of the download buttons the error 414 displays.

I am storing the images in my database using Longblob

Does anyone know why this is happening.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
    • ¥15 linux驱动,linux应用,多线程
    • ¥20 我要一个分身加定位两个功能的安卓app
    • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
    • ¥15 IAR程序莫名变量多重定义
    • ¥15 (标签-UDP|关键词-client)
    • ¥15 关于库卡officelite无法与虚拟机通讯的问题
    • ¥15 目标检测项目无法读取视频
    • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
    • ¥100 求采集电商背景音乐的方法