Returning Javascript after file upload to php

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CpVermont
    New Member
    • Feb 2008
    • 14

    Returning Javascript after file upload to php

    Well this should be a fiarly simple question to those of you who are experts at php. I have some Javascript on the Client side that uploads a file to a php on my server through a hidden Iframe. I want to return some Javascript to the Iframe.[ <script type='text/javascript'>par ent.myObject.my ResponseVar = $response;paren t.myObject.dclo se();</script>]. $response is a php string var that contains the file upload stats (file name Kbs was successfullly uploaded!) or the error code. Any help you could give me will be greatly appreciated!

    Thanks,
    Chris
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by CpVermont
    Well this should be a fiarly simple question to those of you who are experts at php. I have some Javascript on the Client side that uploads a file to a php on my server through a hidden Iframe. I want to return some Javascript to the Iframe.[ <script type='text/javascript'>par ent.myObject.my ResponseVar = $response;paren t.myObject.dclo se();</script>]. $response is a php string var that contains the file upload stats (file name Kbs was successfullly uploaded!) or the error code. Any help you could give me will be greatly appreciated!

    Thanks,
    Chris
    Is it using AJAX?...
    If yes, then you can call a function in the onreadystatecha nge function when xmlHttp.readySt ate==4 && xmlHttp.status= =200.

    In that function you can manipulate the response text.

    Comment

    • CpVermont
      New Member
      • Feb 2008
      • 14

      #3
      Originally posted by hsriat
      Is it using AJAX?...
      If yes, then you can call a function in the onreadystatecha nge function when xmlHttp.readySt ate==4 && xmlHttp.status= =200.
      In that function you can manipulate the response text.
      I am avoiding AJAX because when I use an xmlHttp request to post to my php using the POST method my php only recieves about 900 bytes of the file. The file is an advertiser list and is now 9 Kb's, but will be much larger when the site comes online. In my php I'm using the super global $_REQUEST $fileName =$_REQUEST['fileName'], $fileString=$_R EQUEST['contents']. So to post the file I use an hidden Iframe and an old fasioned html hidden input. The workaround I've been using is to have my php write a file mysavestats.txt and then when the Iframe closes I use an ajax post to get the contents of the mysavestats.txt . I would rather have my php send the results of the upload to the iframe in javascript that sets a variable's value in the parent window to the results. Thank you for your response tho.

      Comment

      • CpVermont
        New Member
        • Feb 2008
        • 14

        #4
        Originally posted by CpVermont
        I am avoiding AJAX because when I use an xmlHttp request to post to my php using the POST method my php only recieves about 900 bytes of the file. The file is an advertiser list and is now 9 Kb's, but will be much larger when the site comes online. In my php I'm using the super global $_REQUEST $fileName =$_REQUEST['fileName'], $fileString=$_R EQUEST['contents']. So to post the file I use an hidden Iframe and an old fasioned html hidden input. The workaround I've been using is to have my php write a file mysavestats.txt and then when the Iframe closes I use an ajax post to get the contents of the mysavestats.txt . I would rather have my php send the results of the upload to the iframe in javascript that sets a variable's value in the parent window to the results. Thank you for your response tho.
        I'd like to thank hsriat for at least responding to this. I know the question may have sounded stupid to those of you who are seasoned php programmers, but I know very little php. I'm a fairly decent Javascript programmer, but anyway I have solved my own problem. After setting up an apache and php on my computer I am able to experiment with php without having to constantly download and upload to my rented serverspace. So this will close this thread. You just use add this to the end of your return string [ "<script type='text/javascript'>dat aFeed.dclose.ca ll(); </script>";] . Simple! Remember just put whatever javascript you betwen script tags at the end of your return string!
        Later!

        Comment

        Working...