在文本输入表单中输入代码,怎么办? [英] Type code in to a text input form, how?

查看:86
本文介绍了在文本输入表单中输入代码,怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道将 $ imagepath写到此输入中的最佳方法

I want to know the best way of writing out my "$imagepath" in to this input

这是我的上传脚本

<?php
        if(isset($_POST['submit'])){
          if (isset ($_FILES['new_image'])){
              $imagename = $_FILES['new_image']['name'];
              $source = $_FILES['new_image']['tmp_name'];
              $target = "temporary_images/".$imagename;
              move_uploaded_file($source, $target);

              $imagepath = $imagename;
              $save = "temporary_images/" . $imagepath; //This is the new file you saving
              $file = "temporary_images/" . $imagepath; //This is the original file

              list($width, $height) = getimagesize($file) ; 

              $modwidth = 350;                         
              $modheight = 100; 

              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
              $image = imagecreatefromjpeg($file) ; 
              imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 

              imagejpeg($tn, $save, 100) ; 

              $save = "temporary_images/sml_" . $imagepath; //This is the new file you saving
              $file = "temporary_images/" . $imagepath; //This is the original file

              list($width, $height) = getimagesize($file) ; 

              $modwidth = 80; 
              $modheight = 100; 

              $tn = imagecreatetruecolor($modwidth, $modheight) ; 
              $image = imagecreatefromjpeg($file) ; 
              imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; 

              imagejpeg($tn, $save, 100) ; 
            echo "Large image: <img src='temporary_images/".$imagepath."'><br>"; 
            echo "$imagepath"
          }
        }

是我的表单

<form>
 <input name="animeinput" id="animeinput" size="20" class="textbox">
</form>


推荐答案

如果您可以将var用于标记:

If you've got the var available to the markup:

<form>
   <input name="animeinput" id="animeinput" size="20" class="textbox" value="<?php echo htmlspecialchars($imagePath); ?>" />
</form>

这篇关于在文本输入表单中输入代码,怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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