Put the php in a controller and over wrote some of the uploadify methods to better handle errors. A hidden input with the uploaded files name also gets appended to the form if the upload is successful.