views:

233

answers:

1

i am making website of yellopages in which i want to uploade and display image on same pages. firstly i insert image name in database while uploading.now i want to get image name on parrant page my code is bellow

addproduct.php

       <table width="100%" border="0" cellspacing="0" cellpadding="0">
                         <tr>
                           <td width="42%" align="right">Product Title </td>
                           <td width="1%">&nbsp;</td>
                           <td width="118" height="118" align="center" bordercolor="#FFFFFF" bgcolor="#FFFFFF" ><iframe src="" id="fileframe" name="fileframe" width="118" height="118" scrolling="no" frameborder="0"></iframe></td>
                         </tr>
                         <tr>
                           <td align="right">&nbsp;</td>
                           <td>&nbsp;</td>
                           <td onclick="whatever();">value</td>
                         </tr>
                         <tr>
                           <td align="right">&nbsp;</td>
                           <td>&nbsp;</td>
                           <td><label>
                            <input name="thefile" type="file" id="thefile" />
                           <a href="#" class="uploadfile">upload</a></label></td>
                         </tr>
                         <tr>
                           <td align="right">Product Description </td>
                           <td>&nbsp;</td>
                           <td>&nbsp;</td>
                         </tr>
                         <tr>
                           <td align="right">&nbsp;</td>
                           <td>&nbsp;</td>
                           <td>&nbsp;</td>
                         </tr>

                         <tr>
                           <td colspan="3"></td>
                           </tr>
                         <tr>
                           <td>&nbsp;</td>
                           <td>&nbsp;</td>
                           <td><label>
                             <input name="web" type="submit" id="web" value="Continue" />
                           </label></td>
                         </tr>

                       </table>
                        </form>

java script in this page is

             function whatever(){
                      mmspobj=document.getElementId("fileframe");
                      // if (mmspobj.tagName=='iframe'){
                      //alert("hi");
                                                               //mmsiobj=window.frames[fileframe].document.getElementId('fileframe').value;
                      alert(mmspobj);
                     //}
                             }

uploader.js is

             function init()
                      {
                       fileUploadEvents();
                      }

                 function fileUploadEvents()
                       {
                     var links = document.getElementsByTagName("a");
                     if (links)
                          {  
                         for (var x=0; x<links.length; ++x)
                        {
                               if (links[x].className == "uploadfile")
                             links[x].onclick = uploadFile;

                      }

                    }
             }

              function uploadFile()
                    {
                  var uploadForm = document.getElementById("uploadform");
                if (uploadForm)
                     {
                       uploadForm.target="fileframe";
                         uploadForm.action="upload.php";
                             }
                    uploadForm.submit();
                    }

now i want to get iamge name in addproduct.php

A: 

You might find it easier to have the iframe call a JavaScript function in the parent, rather than have the parent window try to read the name from the iframe.

Jeremy Stein