I'm creating a website that is able to do multiple file uploads. However, is it possible such that when I click on the browse button and select the file to upload, it automatically adds it to a list of files to be uploaded, instead of selecting the file, and having another button to add that selected file to the list? It is something like uploadify.
Thanks.
I use Ajax Uploader for this
Latest build of Ajax Control Toolkit allows you to upload files without refreshing a page and without using addition button (not sure for multiuploading).
Also you may be interested in "[How Do I:] Multiple File Uploads in ASP.NET 2".
Related
I am working on a form on a page that uses an asp:FileUpload to allow users to upload files to a server. I'm new to ASP and am using C# for my code-behind. The plan is to have the user "attach" files one at a time, adding them to an asp:listbox. Finally when the form is submitted the files in the listbox get saved to the server.
While it seems pretty easy to save files from the FileUpload by using
myFileUpload.SaveAs("path");
I am running into some difficulty figuring out how to keep track of the files independent of the FileUpload. I can get the file names really easily using
Path.GetFileName(myFileUpload.PostedFile.FileName);
but really I need to have some way of keeping track of more than just the names. My first thought was maybe to use a temporary folder of some sort, but the files are going to potentially be pretty large so I don't want to do that because saving might take a while.
How can I keep the file around so that I can save it on the server later independent of the FileUpload?
Rather than using a ListBox I would use actual <asp:FileUpload> controls so you can have access to all of the methods for that control - such as Save Etc.
You can put a bunch of these on your page and simply hide all but the first one. Then have a button to say "Add Another" - then with the click of this button show the next <asp:FileUpload> control - JQuery would be a nice choice to show the next <asp:FileUpload> that is currently hidden.
Then in your postback you can loop through all of your <asp:FileUpload> controls and if it HasFile - which is a property on the control - then perform your saving etc.
Save them into a temporary folder if needed - perhaps renaming the file with a GUID and store this list of GUID's in the users Session so you can grab those when needed.
Once you call SaveAs, you're saving the file. The base FileUpload control won't allow you to cache the file somewhere without actually uploading it to the server first. If you are looking to upload multiple files without uploading until the end, you may need to look into dynamically generating FileUpload controls (as many as the user wants). That way they can select the files to upload one at a time, then hit an "Upload" button at the end.
It's a little clunky to do it that way, though. I'd look for some third-party multiple upload controls. I've used PLUpload in the past.
What would be the best way to create a C# Web Application that allows the user to browse for an image and then display it?
An equivalent of Picturebox in windows applications, sort of
Ideally the user should be able to click on Browse, choose the picture and see it in the browser itself
Thanks
There are all ready some image-browser for asp.net including source code.
Some of them
http://www.codeproject.com/Articles/17605/Thumbnail-Image-Viewer-Control-for-ASP-NET-2-0
http://www.codeproject.com/Articles/29846/A-simple-ASP-NET-AJAX-image-browser
For this, the user needs to choose an image which will be uploaded to the server, and then rendered in the HTML or recovered using AJAX. The problem is that you can't get rid of the send/receive, and it can get slow.
You can use a FileUpload or any other component that allows to upload files directly or via AJAX (look at AjaxFileUpload AjaxControlToolkit for this).
Then you need to add an <img> to your page, through a full postback or using any other means (like jQuery.Ajax).
I'm trying to upload some files to an ftp server from an ASP.NET page. Everything is ready however I would like to use an open file dialog to select the files I want to upload. How can I enable file upload to select multiple files, and if I can't, can I simply use the OpenFileDialog like a normal windows forms application ?
Thanks in advance
The issue is that in the context of a web application, you post data as a KeyValuePair. So a single <input type="file" name="Something" /> element can contain only one file because it is only one key.
An OpenFileDialog would be executed server side in a window there; the client would never see it.
Your options are to either limit to 1 file (and have a button to add another file upload), or move to a gmail like approach where you use a flash / plugin to get that functionality.
The standard HTML browse dialogue won't let you. However, there's a video on the official ASP.NET site called Multiple File Uploads in ASP.NET 2 that you should look at. There's some code based on that here.
Generally you would either use a Flash or JavaScript/AJAX based solution. There are plenty of controls available that can do this eg.
http://www.codeproject.com/KB/aspnet/multiple_file_upload.aspx
http://swfupload.org/
http://ajaxuploader.com/
Just google 'multiple file upload' for far more.
Set OpenFileDialog's MultiSelect property to true.
You may want to look at these SO posts:
How to select multiple files for upload?
Selecting Multiple Files for Upload in Web Page
Have a look here on how to upload multiple files. You have multiple FileUpload controls and use HttpFileCollection to get the files.
http://www.dotnetcurry.com/ShowArticle.aspx?ID=68&AspxAutoDetectCookieSupport=1
i also research on this point but there is no a way to select a multiple file at one file control beacuuse the limitation of the file controll is select only one file at the time
so you will take multiple file control for import multiple file
Hi i'm currently working with the CyberStride.Contacts module in Orchard and have been trying to add a file upload to the form, but there seems to be a problem somewhere because the files never upload. Has any one successfully add a fileupload to a module in Orchard, if so could you share how you accomplished this. Thanks.
In order to be able to upload with a form, that form needs to be multipart. This is why it doesn't work without a couple of tricks.
You can find an example of a file upload in this module: http://orchardproject.net/gallery/List/Modules/Orchard.Module.Contrib.ImageField
Note now there is a FileUpload field here:
http://orchardproject.net/gallery/List/Modules/Orchard.Module.Contrib.FileField
Once you install this
Click Content Types on the dashboard.
Click Edit on the Contact Page type.
Under fields, click Add, and add File Field.
Thats it!!
When you add a contact form a file upload field will automatically show.
I am trying to create a wizard using jquery (fill in a dialog of info, press next, dialog changes but page does not refresh). During this process I would like to upload a file to a document library. I do not wish to reload the page. Is this possible? How would you go about doing this?
You can use uploadify plugin here, which uses a flash component to upload files and it provides events for almost every state of uploading, so you can fire your functions whenever you want for changing content showing alerts etc...
As redsquare says there are also other plugins, but i used this one in a project and it works pretty well.
Hope it helps,
Sinan.