Asp.net fileUploader(brettle.web) is not working on post back - asp.net

I am using a third party file uploader which is same as asp.net file uploader control.
On a page before post back(clicking a button in gridview) the file name gets empty from file uploader and on code behind can't get file.
There were update panels on page. I have also removed them but no affect.

I've checked the Brettle.Web FAQ http://neatupload.codeplex.com/documentation and found the following answer to a very similar problem:
Q: Why are filenames cleared on postback?
A: Browser security restrictions prevent the server from set the names of files to upload.

Related

Dynamic destination with AjaxFileUpload

I am using an AjaxFileUpload for multiple file upload. It is working, but I want to change the destination with the value in a textbox. The code is below which is in the AjaxFileUpload1_onUploadComplete method:
string myDir= myDirTextBox.Text.Trim();
AjaxFileUpload1.SaveAs(Server.MapPath("../allarticles/"+ myDir+"/"+e.FileName));
I debug the project and write a name in the myDirTextBox. Then when I click the Upload File button the value of this textbox is always null. That's why I can't change the destination dynamically.
I have read this article but it is not clear: upload multiple files with ajaxFileUpload with different file ids
What is the problem and how can I solve it?
When server event occurs the page goes through complete page lifecycle.
That means your code deals with new, uninitialized version of a page which is not related in any way with the page you see in a browser.
To save the value of a textbox and utilize it later you need to write some code to store this value between page requests. This can be simple JavaScript code attached to Upload button, that posts textbox value with AJAX to a server. Server, in turn, will store this value in session or another persistent storage.

Browse file dialog

How can I add a file browse functionality on my asp.net web form ?
I have a similar button in my winforms app and now I need it on asp.net my web page.
FileUpload control is used to select and post file to a web server, I just need to select file path/name without sending file.
Should I add some JS to delete FORM item before doing POST or any other simplier solution exists ?
Follow this.
You can use asp:FileUpload , when user selects a file, you need to get that path using this - document.getElementById("fileeupload_id").value. Save this value to hidden field , say with id hdn.
Reset file selection using this - document.getElementById("fileeupload_id").value = "".
So that, when page will be posted, you file will not be posted,rather filename will be posted as hdn.Use Request.Form["hdn"] to get selected file path.

Problem with saving attached files using FileUpload control in ASP.NET

In my website,I have a home page in which by clicking on an image button,I get redirected to a different .apsx page .This page consists of a FileUpload control and 2 buttons(ATTACH,CANCEL).When a user selects/browses a file from his local machine and click ATTACH button,I display that file in a GRIDVIEW and also push the details of that file like Filename into a DATATABLE.
The user in this way can browse multiple files and all of them are added to GridView and also pushed to DATATABLE.Now when the user clickes CANCEL button,I am sending the whole DATATABLE in a session object to the HOME page.Upon clicking SAVE button in the home page,the files in the DATATABLE must get stored in a physical location that I mention in the code.
The problem that I am facing is that when I write
FileUpload fl=new FileUpload;
fl.SaveAs(dt["fileName"]);
The files are not at all getting saved in the location.
However If I pass the FileUpload control using Session from the second page,
FileUpload fl=(FileUpload)Session["FileUpload"]
The files are getting saved with the correct filenames but the content of all the files consists of the content of the latest uploaded file.I know what the problem is but unable to get a solution.
My Requirement is to save the files in a physical path only after clicking the Save button in the home page.Kindly Suggest me..Thanks in advance!
I believe that the asp.net FileUpload control only supports uploading of one file at a time. that is why you only see the contents of the last file. You either need to create a separate control for each upload, roll your own, or use a 3rd-party vendor control.

asp.net mvc Upload File ajax

Hi ive got an mvc form with a fileupload functionality. Ive got an action that accepts an file and extracts thumbnails from it, after which the user can select the images and then proceed to submit the form. How can post the initial file via ajax, bearing in mind, this is not the final submission on the form and I want to retain user input. ie no postback
Thanks
I use the ajaxupload plugin for jQuery. Lots of sample code is provided on the site. From the site:
[The] plugin creates invisible file input on top of the button you provide, so when user clicks on your button the normal file selection window is shown. And after user selects a file, plugin submits form that contains file input to an iframe. So it isn’t true ajax upload, but brings same user experience.
Browsers don't allow the uploading of files via ajax. There are several good workarounds, however.

ASP.Net file upload with an empty posted files collection

I have an ASP.NET file upload control which sits as part of a form. The file upload control is on the content page while the form definition is on a master page across the site. I've added multipart/form-enc to the form on the master page.
I'm using jQuery to submit the form as I show a dialog box from jQuery UI.
When I post, no file is returned to the server. The file upload control has no file and HttpFileCollection is empty. How can I find the posted file?
Most dialogs take your content, wrap it, and place the result just before </body> in the page...this is a problem in ASP.Net because that's outside the <form></form>, it needs to be inside to be included in the POSTed data.
When you create the dialog, make it append inside the <form> when it finishes instead of the <body>, for example this is what you'd do with the jQuery UI dialog:
$("#myDiv").dialog({ ...options... }).parent().appendTo("form:first");
Now that it's been moved inside the <form>, it should post correctly.

Resources