Jump to content

Bringing The Value To Form Field


arunpatal

Recommended Posts

Hello everyone, please help me with this problem

 

Here is the code of adding items page

 

<td><label for="item_image"></label>
	 <input type="text" name="item_image" id="item_image" />
	 <input type="button" name="button" id="button" value="Upload Image" onclick="javascript:uploadimage();" /></td>

 

<script>
function uploadimage()
{
self.name = 'opener';
remote = open('item_image.php', 'remote',
'width=400, height=200, location=no, scrollbars=yes, menubars=no, toolbars=no, resizeable=yes, fullscreen=no, status=yes');
remote.focus();
}
</script>

 

Now it popup the new windows and open item_image.php

 

 

Here is the code for item_image.php

<?php if ((isset($_POST["send"])) && ($_POST["send"] == "form1")) {

$image_name = $FILES['userfile']['name'];
move_uploaded_file($_FILES['userfile']['tmp_name'], "../item_image/item/".$image_name);
?>
<script>

opener.document.form1.item_image.value="<?php echo $image_name; ?>";
self.close();
</script>

<?php
}
else
{ ?>
<form action="item_image.php" method="post" enctype="multipart/form-data" id="form1">
<p>
<input name="userfile" type="file" />
</p>

<p>
<input type="submit" name="button" id="button" value="Upload Image" />
</p>

<input type="text" name="send" value="form1"/>

</form>
<?php
}
?>

 

 

The problem i am facing it that the name of file dose not show in field

 

<label for="item_image"></label>
	  <input type="text" name="item_image" id="item_image" />
	  <input type="button" name="button" id="button" value="Upload Image" onclick="javascript:uploadimage();" />

 

which is in adding item page...

and it also dose not upload the image file to server...

Link to comment
https://forums.phpfreaks.com/topic/272289-bringing-the-value-to-form-field/
Share on other sites

Review your variables, in particular wherever you've attempted to use $_FILES. You're also missing an input field of type "file" which is used to create the array the $_FILES variable points to. There's absolutely no need to go and use Javascript for this either unless you want to create a Javascript uploader.

 

http://goo.gl/W9q8B

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.