0

I have a web form that requires users to fill out some information and upload an image.

What I don't understand:

  1. If I use uploadify to select a file doesn't it upload it right away to the server? Is there a way to defer that until the user would click on a form submit button? Or at least not save it to the file system?

  2. Most examples use a custom HttpHandler for uploading files, but my file upload is part of a form. Should I still use a HttpHandler for that?

chobo
  • 31,561
  • 38
  • 123
  • 191

2 Answers2

2

Well, I'll try to answer all your many questions, one by one. But before anything, open the official documentation because I will rely on it for answers.

  1. If I use Uploadify to select a file doesn't it upload it right away to the server?

    As you can see on the first demo, you can have a anchor (or a button or anything) to trigger the upload start. The Uploadify don't upload nothing until it's done (if the property auto isn't true).

  2. Is there a way to defer that until the user would click on a form submit button?

    Like described above, yes. And it's the default way (since the default value of auto is false).

  3. Or at least not save it to the file system?

    While the button doesn't trigger the .uploadifyUpload() method, nothing goes to the server. But when the Uploadify starts sending, it will be handled by the server (with the HTTP Handler). The handler is the guy that save it to the file system.

  4. Most examples use a custom HttpHandler for uploading files, but my file upload is part of a form. Should I still use a HttpHandler for that?

    As described on the script property, you can point to any server-side language that will handle the HTTP Request containing the data. The HttpHandler is the right thing because it haven't any other processing before or after the code you write. It isn't hard. The official forum shows some samples. And here on StackOverflow we have many questions about it, like these: Getting Uploadify Working in C# and Uploadify not working with ASP.NET WebForms.

Community
  • 1
  • 1
Erick Petrucelli
  • 14,386
  • 8
  • 64
  • 84
  • I came across the Auto:false property which defers the uploading. The problem I have now is that when the user clicks on the submit button it will go through my server-side validation, but then at the very end of the validation I need it to call the .uploadifyUpload() method. How can I call this from the server-side? – chobo May 30 '11 at 16:05
  • 1
    This is impossible. The strategy here needs to be the inverse: use the [`scriptData`](http://www.uploadify.com/documentation/options/scriptdata/) property to send all your form fields with the file upload request. Then your HTTP Handler can validate the received data and then continue saving the file only if the data is valid. – Erick Petrucelli May 30 '11 at 16:44
  • That's what I thought because you have two threads going one synchronous and the other async. The scriptData I think is the only easy way of handling this, thanks! – chobo May 30 '11 at 17:21
0
  1. The server shouldn't save the file until it is actually actioned by a handler. The Uploadify is providing the UI control for the gathering of the files and feedback. There are some settable properties available to control whether you want the "Auto" upload behavior or not.
  2. You still need some king of server side processing for saving the data and an HTTPHandler is the usual way to do it. The HTTPHandler just operates on what file information it gets from the browser as part of a multi-part form data.

Here is an answer that provides more information about Uploadify: Getting Uploadify Working in C#

Community
  • 1
  • 1
Turnkey
  • 9,266
  • 3
  • 27
  • 36