views:

59

answers:

2

Hello! i have this image upload script.

 <?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>"; 
          }
        }

I need the script to write the name of the file in the form

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

So basically i need my upload script to write $imagepath (the filename that is used for storing the image) into the form when an image has been uploaded.

How do i do this?

A: 

I'm not completely sure what you mean, but this should work:

<form> 
 <input value="<?php echo htmlspecialchars($imagepath); ?>" name="animeinput" id="animeinput" size="20" class="textbox"> 
</form>
Tom Haigh
+1  A: 

If you're wanting to add to your script, which you previously mentioned is displaying the image, then is this what you mean?

...
echo "Large image: <img src='temporary_images/".$imagepath."'><br>"; 
echo "<form>";
echo '<input type="text" value="' . $imagePath . '" name="animeinput" id="animeinput" size="20" class="textbox">'; 
echo "</form>";
...
David Archer
This is exactly what i wanted!Thanks a bunch!
glad to help :-)
David Archer