File upload multi-select - c#

I'm not positive if this is even possible, but is there any way to enable a user to ctrl+click (ie, multi-select) files on a website?
Screen shot of what I would like to be able to do via an upload tool, taken from just my standard file explorer:
In case this is relevant, the back-end of the site is in C# and the front-end scripting is JS/jQuery.

HTML4/XHTML1's file upload element only allows for single file uploads. You can use Flash or a plugin to get the behavior you want. You could use JQuery to create a dynamic form that would allow multiple uploads but they'd still need to be selected individually.
If you're OK with only supporting HTML5-capable browsers, you can <input type="file" multiple="multiple> and get this behavior.

Related

Set Default Directory for Lotus Notes File Upload Control

I have a lotus notes web form in which computer-illiterate customers will use to attach Excel files and submit them to our company. I am using a Lotus Notes File Upload Control to allow them to do this, however, I need to default this File Upload Control to a certain directory location. I have already created a C# application the customers will be using, which places all of these excel files in a certain directory location, hence the reason I need to focus this File Upload Control. Unfortunately, some of the customers are computer challenged enough to not know how to navigate to these files on their own. Is this possible at all?
I'm assuming the users will be visiting a web page with the File Upload control, yes? If I'm misunderstanding please let me know and I'll delete this answer.
The simple answer is it isn't possible. The problem is that the browser can't know anything about the file structure of the clients that visit the site, so a "default path" property doesn't really make sense. It would likely only work in very specific environments (which is maybe true in your case, but not across the web in general)
I would investigate using the Notes API to have the C# program handle the upload without involving the browser client use of the file upload control. I don't know enough Java to be sure, but perhaps that might also be an option -- basically writing your own custom upload control that only asks the user for the filename.
You may also be seriously underestimating the ability of the users to follow directions. If your page identifies which directory the file will be found in, I expect most users will be able to follow the directions and upload from the correct directory.
So, I'm sure that accomplishing what you want to accomplish is possible in Notes, just not as simply as adding a default directory to the File Upload Control.

c# browse for a image on web applications and display it

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).

Upload items from user computer to a server asp.net

I don't really know how to explain what I want to do.
I will try to explain what I am doing. I built a website in ASP.NET 4 (WebForms) and I want that my brother will be able to click on a button, choose a file from his computer and it will be uploaded to my server.
I have no idea how to do it. It sounds very hard to do and I am really stuck with this for a few days now.
I don't care if it will be with JavaScript, HTML or C#, I just really need it to work.
There's an ASP.NET control made just for that, the FileUpload control. Here's a handy example.
Note that it's notoriously difficult to style if you want to apply CSS and make it elegant, but there are more advanced ways around that. Also, this won't give your web application access to the client's local files or anything like that, it's just a standard file open dialog box for the user to select a file and upload it.
I also highly recommend doing a lot of input checking when accepting files. File type, file size, etc. are all important.
you have 2 options really.. use a traditional fileupload control (from the toolbox) or use the Ajax AsyncFileupload control.
either way it will allow your brother to upload a file from his computer to your server.

Using ASP.NET, how can I select multiple files through the same dialog

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

Download multiple files from one link

I would like to open multiple download dialog boxes after the user clicks on a link.
Essentially what I am trying to do is allow the user to download multiple files. I don't want to zip up the files and deliver one zipped file because that would require a lot of server resources given that some of the files are some what large.
My guess is that there may be some way with javascript to kick off multiple requests when the user clicks on a certain link. Or maybe there might be a way on the server side to start off another request.
Unless the client is configured to automatically download files, you can't accomplish this without packaging the files in a single response (like ZIP solution you mentioned.) This would be a security issue if a Web site would be able to put arbitrarily large number of files on your disk without telling you.
By the way, you might be overestimating the cost of packaging in a single file. Streaming files is usually an I/O-bound operation. There should be enough CPU cycles to spare for piping the data through some storage(tar)/compression(zip) methods.
If you absolutely, positively cannot zip at the server level, this would probably be a good instance for creating some sort of custom "download manager" client-side plugin that you would have the user install and then you could have complete control over how many files you downloaded, where they went, etc.
I suppose you could link to a frameset document or a document containing iframes. Set the src of each from to one of the files you want to download.
That said, a zipped version would be better. If you are concerned about the load then either:
zip the files with compression set to none
use caching on the server so you zip each group of files only once
Present a page with a form of check boxes of the available files for download - with multiple select enabled for the check boxes.
User selects multiple files and submits forms.
Server accepts request and creates a page with serial-triggered file download javascript.
The page with the embedded javascript is presented to the user's browser, listing and asking for confirmation the files to be serially downloaded.
User clicks [yes - serially swamp my harddisk with these files] button.
foreach file, listener for download completed triggers the next download, until end of list.
I only know how to do this using Google GWT, where I had set up GWT RPC between browser and server. Took me two weeks to understand GWT RPC and perfect the download. Now it seems rather simple.
Basically (do you know basically is one of the most used non-technical words among the geek community?), you have to declare a server service class specifying the datatype/class of transfer. Where the datatype must implement serializable. Then on the browser-side the GWT client declares a corresponding receiver class specifying the same serializable datatype. The browser side implements a listener for onSuccess and onFailure.
Hey, I even managed to augment GWT service base class so that I could use JSP rather than plain servlets to implement the service interface.
Actually, I was not downloading a series of files but streams that conditionally serially triggered the next stream, because my onSuccess routine would inspect the current stream to decide what content to request for on the next stream.
Ok, two weeks was an exageration, it took me a week to do it. A genius would have taken half a day only.
I don't see what the big deal is with this. Why not something like this:
Click me
<script type="text/javascript">
$('a#myLink').click(function() {
window.open('http://www.mysite.com/file1.pdf', 'file1');
window.open('http://www.mysite.com/file2.pdf', 'file2');
window.open('http://www.mysite.com/file3.pdf', 'file3');
});
</script>

Categories