I am using Plupload for multiple file uploads. The files are sent to a ashx handler which saves them. However, I also have a Fileupload control for users who do not have flash or javascript enabled. I am wanting to use the Handler to also handle uploads from the fileuplaod control so all my logic is kept in one place. Does anyone know if it is possible to send the file from the fileupload control to a handler?
Thanks in advance
I am not sure about how the fileupload control works. But you can try to create a workaround and have your logic in one place i.e to create a class that handles the uploaded file. Now both your handler and fileupload control will use this class to do the necessary with your files.
Related
I have a form with FileUpload control. Say, user chooses a file from his local disk, uploads it and then my site tells him that the file is in wrong format. The FileUpload control still retains the path to file.
Then the user makes neccessary corrections to his file and presses the upload button, assuming it will grab the updated version of his file. But the server still receives the old version of file, which is without user corrections! I even noticed that you can even rename or delete the local file after choosing it with FileUpload and it will still upload.
So my questions are:
Does FileUpload control cache files in some fashion?
Is this ASP.NET functionality or it's present in basic HTML control?
Can I remove this caching so that server always gets the latest version of the file?
Try using fileuploadId.Dispose() on pageload to clear the control.
I am using Uploadify plugin for asp.net web appication.
I want to let user delete an uploaded file. For this, I used onCancel event of Uploadify.
But, the problem is, if the page refreshes/postbacks, the FileUpload queue of Uploadify gets clear automatically.
How do I keep the queue-items as it is on Postbacks?
How do I delete files on server after they are automatically uploaded?
Do I need to write code in Upload.ashx or in codeBehind file of the webpage?
You need to store file upload status in database on file upload completion, at onCancel event just check (create handler with ajax call) whether there is already uploaded item stored, if yes then delete it.
There is no way to keep track of uploaded item once postback happen, all you need to store data in some sort of states (session, cookie) or in database.
I need to create a custom web control which will be a part of a class library. This custom web control implements the upload functionality. I have implemented this with a web user control where I have a fixed path to a page in the web project where the upload of files take place and it works just fine.
The created control in this class library is used in the web project. How do I post the uploaded file to a page, say SomeClass.cs, in the class library.
Thanks in advance.
You can use a file upload control to post the file to a code-behind file.
Pass the system path as a string overload?
string systemPathToFile = Server.MapPath("~/UploadedFiles/" + Path.Filename(fuFileUpload.Filename));
In my site, user want to upload a pdf file and I have to save it into my own server. I don't need the content to be saved. I want the exact file to be copied into my server where the published file of the site exists.How to do this?
Use FileUpload Control and write code like
FileUpload1.PostedFile.SaveAs("Path and Filename");
You can easily use asp.net fileupload control: Uploading files in asp.net using C#
You can use ASP.NET file upload control which will handle this.You can mention where in your server you want to store it
I have a Wizard control with one of the pages containing a FileUpload control. I want to access the file stream at the point of the final page of the wizard but this doesn't seem to work.
As far as I can see, you can only access the file stream for the posted file on the postback which occurs immediately after the control has been used. As the file will ultimately be put into a DB record I could save it at this point, but I'd rather avoid this if possible.
Does anyone know of a workaround for this problem?
I've not used this control myself but as it's based around the HTML standard INPUT control I think you are stuck with having to receive the file on the post-back that processes that control.
The difficulty in circumventing this would be around how to pull the file from the client system when you are effectively sandboxed from the local filesystem, hence the need for the upload control.
I would suggest that you store the file into your DB blob (or as a temp file on the filesystem, probably need a unique filename; I find a GUID works nicely) and then use the Session object to retain that reference to the end of the process. The only other alternative I can think of that doesn't involve major work would be to move the file upload to the last page of your wizard.
You could have the displaying of your individual wizard stages managed client-side using CSS/jQuery rather than keep POSTing back to the server? That way, your only POST (resulting in the upload) will be at the end of the Wizard.