Hello, I am trying to modify your code so that I can use a Windows Form to submit the file for download? I have tried so many other .net complient components that I am not even sure that this is possible.. However since this is Open Source (thankyou(x)3) I was wondering if I could modify the InputFile object. I was thinking of (since I know which file I want from the Contex.Request.File collection within the Control_Load method) I would just hard code it for the time being for testing purposes. I appologize in advance because I am very green to this tecnology.
I'm afraid I really don't understand what you are trying to do. To help, I need you to describe what you are trying to accomplish and what you want the user experience to be. For example, you might say "When a user clicks a button in my desktop app, a specific hard-coded file is uploaded to my server. No file selection is displayed, but a progress bar is displayed during the upload." If that's what you are looking for, please says so, otherwise please try describing the desired user experience in similar terms.
Sorry for the confusion. But it seems that you did in-fact grasp the core of what I am trying for the user to experience. I would like to know if there is a way for the user to press a button on the desktop, and send a file to my server. I would not like for there to be any popup’s for html progress, I would like for the progress to be sent back in a response that i will listen for, and I will then create a desktop progress meter/metrics display?
I appreciate your considerable efforts within this area of CS, and again I apologize for not being specific enough.
[3/4/2006 Updated for NeatUpload-trunk.240 (and later) and NeatUpload-1.2] Thanks for the clarification. NeatUpload could help you achieve what you want, but it is only part of the solution. Here's how I'd go about it if I were you:
On the client side, when the user clicks the button, the first thing you need to do is generate what I call a postBackID. This is just an globally unique identifier (GUID). I use a hex-encoded 128-bit (16 byte) cryptographically secure random number for the GUID in NeatUpload's FormContext constructor (FormContext is used by InputFile). You could do the same or use something else. Next, create a new Thread to send the file to the server. On that thread, use an HttpWebRequest to send a "multipart/form-data" request (using the POST method) to an URL of the form "http://yourserver/path/to/YourUploadPage.aspx?NeatUpload_PostBackID=postBackID" page, where YourUploadPage.aspx contains a NeatUpload InputFile control. The request would contain the file you want to upload and, in the "Content-Disposition" header for that part of the request, would contain the attribute-value pair "filename=nameOfFile". It would also contain a "name" attribute, whose value would match the ID of the InputFile control. The codebehind for the aspx page would process the uploaded file however you choose (eg move it to a permanent location). NOTE: You might be able to do the upload using WebClient.UploadValues() instead, but I don't know whether that will generate a "multipart/form-data" request, which is what NeatUpload needs. If WebClient.UploadValues() works, using it would save you the trouble of formatting the request by hand.
While the upload is occuring in the new thread, your original thread would poll the server for progress information. I would do that by polling a custom Progress.aspx page that returns the progress info you want in an XML document. You'd parse the XML doc to get the progress info.
See the "Uploading from a Client Application" section of docs\Manual.html included in the release for more details.
As you can see, if you're new to .NET, you are going to need to learn about threading, making web requests from a client, and creating and using web services. You are also going to need to learn about the format of "multipart/form-data" http requests. However, once you have that knowledge, the actual number of lines of code you need to write shouldn't be particularly high (maybe a few hundred?).
If you are interested in paying me to implement what I've described above, just send me an email (dean at brettle dot com). If not, I hope the above helps you get started and I wish you the best of luck in your endeavor.
You are a genius!!My good fortune find you where ever you may be!! Thank you for both the time it took out of your schedule, and for your speedy response.I’ll get right to work and tell you of the results in a few days :)
First of all, a thousand thanks for writing NeatUpload!You are about to save my life (well, maybe just my sanity and some money).I’m also trying to use NeatUpload from a non-browser application.I have most everything working, but have run into a snag that I can’t seem to figure out.
The issue is that inputFile seems to be null when it shouldn’t be.I know the file makes it to the temporary directory, but that’s as far as I get.I’m developing on Windows with IIS 6.The client application I’m using uses a 3rd party component (Xupload) to do the http (https actually) post.I had to make a few changes in your code to accommodate Xupload since I can’t change what it sends.Xupload sends FILE001 for the name attribute and I don’t have a way to change it.So I send the postbackID as a querystring and then set fileID with the appropriate data in FilteringWorkerRequest.ParseOrThrow() if fileID starts with “FILE”.
I also had to remove checks for IsPostBack since the client application does a post and not a PostBack.
At this point, I’m not even trying to use the progress (Xupload has client side progress), although I would eventually like to use the progress server side to get a status on incoming files.
I hope I gave you enough details.
Is there something obvious that I missed?Any help would be appreciated.
I suspect that you are setting the fileID incorrectly before calling CreateUploadedFile(). Please use a debugger or some logging to determine what value is being passed to CreateUploadedFile() for the fileID, and let me know what that value is. Also, please include the few lines of FilteringWorkerRequest.cs that you changed and the InputFile tag from you aspx. Hopefully, those bits of info will be sufficient for me to diagnose the problem and suggest a fix.
BTW, you said that inputFile is null, but you meant that inputFile.TmpFile is null, right?