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...

Edited by arunpatal
Link to comment
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

Edited by CPD
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.