arunpatal Posted December 22, 2012 Share Posted December 22, 2012 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 More sharing options...
cpd Posted December 22, 2012 Share Posted December 22, 2012 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 Link to comment https://forums.phpfreaks.com/topic/272289-bringing-the-value-to-form-field/#findComment-1400908 Share on other sites More sharing options...
PFMaBiSmAd Posted December 22, 2012 Share Posted December 22, 2012 The value of a type="file" form field is read-only. It can only be set by the browse-to-file dialog box in the browser. Link to comment https://forums.phpfreaks.com/topic/272289-bringing-the-value-to-form-field/#findComment-1400910 Share on other sites More sharing options...
arunpatal Posted December 22, 2012 Author Share Posted December 22, 2012 The value of a type="file" form field is read-only. It can only be set by the browse-to-file dialog box in the browser. you mean the problem is that type="file" is read only? and if so then how can i change it? Link to comment https://forums.phpfreaks.com/topic/272289-bringing-the-value-to-form-field/#findComment-1400915 Share on other sites More sharing options...
arunpatal Posted December 22, 2012 Author Share Posted December 22, 2012 Got the error $image_name = $FILES['userfile']['name']; $_FILES Link to comment https://forums.phpfreaks.com/topic/272289-bringing-the-value-to-form-field/#findComment-1400940 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.