show file upload progress in .net - c#

I have to implement file upload progress bar in one of my project.But,having searched a lot , i am not able to find how to find bytes of file uploaded.
Can someone tell me how to find bytes of file uploaded in ASP.NET?

You might need to use some third party upload control. Plupload is a nice one you may take a look at.

Try this:
http://mattberseth.com/blog/2008/07/aspnet_file_upload_with_realti_1.html

jQueryFileUpload works well for me, I have some ASP.Net bindings at https://github.com/i-e-b/jQueryFileUpload.Net

The jquery plugin Uploadify is really good, it has built in progress bars for multiple files and has ability to get progress feedback for custom progress bars.
Note: Is only possible to get this type of feedback using Flash (and/or Silverlight I believe) without going a heavier route like ActiveX/Java.
Update:
This is also possible using plain html and javascript, see this jquery plugin for an example:
http://jquery.malsup.com/form/
For asp.net mvc also have a look at this: Can i upload file in jquery dialog in asp.net mvc

i had this issue in our mvc project a month or two ago. after fiddling around on the internet and trying a few different implementations, i ended up on the one suggest by steve sanderson using swfupload. http://blog.stevensanderson.com/2008/11/24/jquery-ajax-uploader-plugin-with-progress-bar/
it will work just fine in 90% of browsers and for the few that don't support flash it falls back nicely. just copy the code and dump it into your project, it worked just fine in our MVC2 project.

Is it the standard upload control with ASP?

Related

How to prevent saving files asp.net mvc 4 application

I 'm currently working on creating a web learning portal using ASP.NET MVC 4, where my clients requirement is that the end user should not be able to save the file. The save restriction is applicable on all video type files, images, pdf, word docs and powerpoint type files.
I understand the following exceptions and the client is good with this:
User can make use of print screen
copy-paste text
I need your guidance how best to accomplish this.
For video, I came across the following link http://www.strathweb.com/2013/01/asynchronously-streaming-video-with-asp-net-web-api/.
Thanks,
Hemant.
I came across this online tool http://www.docspal.com/ but they doesn't seems to provide any API for the developers.
Am I the only one with this requirement :(
It is really hard to stop users from copying documents from the website.
However, just to lower it down, you should be able to disable right click which may at least decrease the number of users that will try to copy your content. Do something like following in jQuery.
$(document).bind('contextmenu', function (e) {
e.preventDefault();
alert('Right Click is not allowed');
});
Refer to this for more.

Make asp.net site more attractive by flash template

I have downloaded a free flash template from http://www.flashmo.com/preview/flashmo_197_bokeh
I want to use this template in my asp.net (C#) website. More specifically speaking, I want to use that color effect ( the color-change that is happening there in the background of the page) in my webpage.. Please help me to do so..
(Please do check the link I have provided. It will help you understand the color-change I am talking about).
Thanks in advance.
This should be fairly straight forward.
Just embed the downloaded swf file in the aspx page as you would with a regular html page.
See an example on: How to embed a swf file into html code?
The hard part is going to be interacting with the swf. This is possible via Javascript, but is gona take some work. In flash action script you can expose variables to javascript. Once that is done, you can call asp.net code from javascript. Both techniques are very well documented on the net. Just google on it.
Good luck ...
Please don't use flash to create a website and don't use 'attractive' to describe a website.

How to create a File Upload with progress data?

I'm developing a web (using asp.net and c#) which has a FileUpload control from asp.net. The upload thing works perfect and as far as I know I can't show progress data (%, bytes transfered, upload speed, time elapsed, time left, progress bar) using the FileUpload control from asp.net because its not asyncrhonous.
I've searched a lot (really) on the internet and I didn't find what i'm looking for and too much info has become a big confusion since I'm not sure about what I have to use.
On my web page I have a file named "UploadFile.aspx" which has a FileUpload control and a button that handles the uploading. On code-behind (UploadFile.aspx.cs) I have all the server-side logic (Upload the file into specific folder, store info about that file into a database, etc. etc) and I don't want to change this.
What I need to know is how to show the progress data to the user while is uploading the file? I can't use 3rd party applications because this is for an important commercial site. It's not a problem for me if I have to learn javascript / jQuery / Whatever but really i'm a bit lost and I don't know how to start.
Thanks for your time and your help guys.
There's some pretty cool solutions out there. Granted, you can code your own, but I'd suggest using a jQuery plugin like Plupload. If you need help setting it up, you can read their documentation.
There are lots of lots of demo code are available on the net to show the progress bar with file upload control in c#, most of them work fine on Local system but never work on the live server, Because You CAN'T USE A FileUpload control for what you want to do. When a user POSTs a file, you have to think of it like a querystring parameter. It goes as one Http Request. If you want to do a progress bar you'll want to look into something that can interact with the server asynchronously.
If you don't want to use any 3rd party that relies on Flash / Html 5, please take a look at this article:
http://vanacosmin.ro/Articles/Read/AjaxFileUpload
This is possible (and if you're using .NET 4.5 GetBufferedInputStream will make your life easier), but it is not very easy, as you'll see.
Basically, if you want a file upload with progress bar that is fully compatible with every browser, you need to handle this server side and give an url where the client (the browser) can check periodically for the progress with 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.

Better approach for my first asp.net project?

Background info: 2 semesters of C#(WinForms), plenty of HTML/CSS skill, brand new to asp.net.
I'm building a site for a friend who's a photographer. It's just a gallery site, but he'd like to be able to update the galleries himself and he's not tech savvy in the least. So I'm using the following approach to the problem:
Using ASP.NET 4 WebForms:
I'm using System.IO to get the names of the folders which represent the "Galleries" and populating a TreeView control for navigation.
When a "Gallery" is selected, I have code that builds a (HTML)list of the image files and populates an UpdatePanel with this list.
As this is all based on the folders/files, I'm building him an secure admin page to upload files to new or existing galleries(folders). He'll also be able to edit(move/delete) the existing files from there.
I got it all to work, which was a nice little victory, but I'm realizing this approach is not optimal, as none of the unique galleries are findable via search engine or even URL; the SEO value is nill; the browser back/forward buttons are useless...
Can you guys/gals recommend a better way to go about this?
Is there a way to modify what I've already done to optimize the project?
I'll gladly start over to do this right.
Thanks
Couple of suggestions, if you are doing this for fun - and want to learn something, consider using ASP.Net MVC instead. Both will work, but doing it with MVC will give you more up-to-date and marketable skills.
Second, unless you really want to write the whole thing from scratch, consider using a package to do most of what you want and then customize it.
Something like this would work quite well: http://www.galleryserverpro.com/ and is open source, free/cheap and well supported.
SInce you are new to asp.net, you can learn a lot by picking thru the open source code and seeing how other people with more experience have already solved the very same issues.
When a "Gallery" is selected, I have
code that builds a (HTML)list of the
image files and populates an
UpdatePanel with this list.
Well, most of your problem is sitting inside this sentence. get rid of the UpdatePanel. When you are making ajax request, you are not able to allow browser history. so SEO, back/forward nav. buttons are always issue with updatepanel.
http://ajaxhistory.com/

Categories