views:

32

answers:

1

Hey folks,

in order to monitor the upload of large video files I'm using the progress bar as shown in the demo that is shipped with the framework. The upload is working fine and the progress is shown correctly.

However, since the form is targeting a hidden iframe, the server response to the initial post request is sent to that hidden iframe.

So here are my questions:

  1. Why do I need to target an iframe in the first place?
  2. How do I display error messages (invalid post requests) or redirects (valid post requests) on the original page, not on the (hidden) iframe?

I know there are various third party solutions to file-uploads out there (uploadify, SWFUpload, etc.), but I wanted to give the zend framework approach a try.

Help is greatly appreciated!

So long,
blaxx

A: 

An upload is a page request. As any new page request, uploads to stop any active javascript running in the current page. As you want to keep your javascript running you delegate the upload page request to an iframe - which then doesn't stop the javascript in you main page. So if you don't target an iframe - the upload request would first stop all javascript running in your page and then do the upload.
Actually the form helper just hides the new page request in an iframe for that.

To be able to show custom responses and stuff you can either modify the evalProgress -function or subscribe to the iframe's onload event (from a javascript pov a iframe is pretty much the same as or html/body tag). For example you could subscribe to the onload event and then read the iframes content by javascript and evaluate it (ajax requests for foreign servers work that way too btw).

Fge
Thanks for the explanation, the first question seems clear to me now :) As regards the second question: If I understand you correctly, using the zend frameworks approach to progress bars basically ruins the concept of server side validation, as in any case I would have to use javascript to evaluate the server response?
Blaxx
If you want to show the result directly as a result page - yes. But you're already using javascript to display the progress bar and to create/start the upload - so it's already ruined. There is no easier way to display a progress bar for an upload as you have to manage two requests at all time (the upload request + the status request). There are ways to create to status bar server sided with an automatic refresh by metatag but I haven't tested this with zf progress bar.
Fge
OK, thanks for your help! Will post my javascript solution as soon as I have one :)
Blaxx