1

Background: I have to support multiple file uploads in IE7-9. I've found uploadify and FileReader which are both flash based. Our current file upload allows the user to select a file, type in a description and check some check boxes. That data is all sent to the upload servlet at the same time and the servlet gets the file data and the description and the checkbox values and stores the file on the server and adds an entry into the database.

The problem: uploadify and FileReader both want to send the file directly to the server, I don't have a chance to add a description or set any flags. I've worked with FileReader some now and can intercept the file instead of sending it to the server. What I would like to do is get the binary data and put it into the form, let the user add the description and then submit the form with the binary file data. I've all ready tried just adding a hidden field to the form but the data didn't seem to come through.

If worse comes to worse I think I could just upload the file and then update the database when the form is submitted, I don't want to do that but I think that would work. Does anyone know of anyway to add the file data to the form and then to get the servlet to recognize that data as part of the form?

1 Answer 1

1

You can pass data along side your upload in Uploadify, just use the formData attribute like this (found here):

<input name='someKey' type='text' value='Some Value'/>
<input type="file" name="file_upload" id="file_upload" />
<script>
$('#file_upload').uploadify({
    // Some options
    'method'   : 'post',
    'formData' : { 'someKey' : $('input[name=someKey]').val() }
});
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.