Click here to Skip to main content
15,886,080 members
Everything / File Upload

File Upload

File-Upload

Great Reads

by Timothy Svecz
Amazon AWS: Setting up FTP on EC2 Windows Instances
by Amogh Natu
This tip discusses the method to allow the uploading of large size files in ASP.NET
by ASP.NET Community
In my case, I use  a FileUpload Control(Id:->FileUpload1), an ImageButton(ImageButton1) or you can use the Image,  a Button Control(Id:->Updatebttn)
by SwarnenduDas
How to fetch an image document from FileNet for a known Document ID

Latest Articles

by Member 13353000
How to upload images on MVC Web App razor pages using ASP.NET Core 2.2
by Yahya Mohammed Ammouri
This article describes how to add a fully client side Multiple File Upload functionality to your page. Include select multiple files at a time, Select from different folders, Apply validation, show files in thumbnails and remove files from the list.
by girishmeena
All the information regarding Ajax file upload control and validation
by Bjørn
A simple explorer and file transfer for files over a telnet connection

All Articles

Sort by Score

File Upload 

15 Jun 2012 by Timothy Svecz
Amazon AWS: Setting up FTP on EC2 Windows Instances
18 Apr 2013 by Amogh Natu
This tip discusses the method to allow the uploading of large size files in ASP.NET
18 Sep 2011 by Arun Kumar K S
Try this file copy method will copy your image to new location with a new namestring fulllocimage = openFileDialog1.FileName;File.Copy(fulllocimage, @"C:\UploadedImage\" + NewImageName);
19 Sep 2011 by Arun Kumar K S
Try this for resizing and save to a new location string strPath = @"D:\MemberImage\MyPhoto.jpg"; System.Drawing.Image img = System.Drawing.Image.FromFile(strPath); img=Resize(img, 160, 120); img.Save(@"D:\UploadedImages\NewImg.bmp"); //resize...
2 Mar 2014 by ASP.NET Community
In my case, I use  a FileUpload Control(Id:->FileUpload1), an ImageButton(ImageButton1) or you can use the Image,  a Button Control(Id:->Updatebttn)
29 Oct 2014 by OriginalGriff
They both end up with the same result, but the first one allows you to read it in smaller chunks if you need to. The FileBytes property always returns a single array which holds the whole file. If for example the file exceeded the .NET 2GB limit on single objects, the second method would fail,...
10 Mar 2011 by R. Giskard Reventlov
If only you could search CP for such an article[^]...
6 Apr 2011 by Ankur\m/
Uploading a file to the server needs appropriate write permission to the account processing your request on the directory you are uploading the file.Check the MSDN link - FileUpload Control Security Considerations[^]
29 May 2011 by yesotaso
If you need info about creating, handling arrays: Array tutorial[^]If you need info about general file reading stuff like ReadAllText ReadAllLines etc:System.IO.File[^]If you arent happy with just File class: System.IO.TextReader[^]If you want a general purpose...
9 Jun 2011 by thatraja
This bunch has the trick.Simple AJAX File Upload[^]File Upload not working with update panel[^]FileUpload in an Ajax UpdatePanel[^]FileUpload control inside an UpdatePanel without refreshing the whole page?[^]FileUpload is not working within update panel[^]
18 Dec 2011 by SwarnenduDas
How to fetch an image document from FileNet for a known Document ID
23 Jul 2012 by fjdiewornncalwe
You are attempting to delete the file that was read in within the thumbnail object. Perhaps if you disposed of the thumbnail object, the file resource would be released.
21 Nov 2013 by OriginalGriff
What does your web server have in it's "E:" drive? Anything? Nothing? Can you even tell? The answer to the last question is "probably no".Server code runs on the server, not the client. So it accesses server hardware, not client hardware. It worked on your development machine because the...
9 Feb 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Refer - upload file directly without "upload" button[^].This thread has discussed exactly what you need. There are many accepted solutions, so follow them.
8 May 2014 by Bernhard Hiller
That's a simple check on the FileName property:if (!string.IsNullOrEmpty(FileUpload2.FileName)){ //your code for saving the image on the server etc.}
3 Sep 2015 by OriginalGriff
If what you are being sent is binary data, then you can;t directly store it in a string, as a string is a collection of characters - and converting binary data to characters rarely means you can convert them back again (as not all character codes are valid depending on the character set being...
2 Mar 2016 by Dave Kreskowiak
You're using UNC paths for both file specifications. A proper UNC path is "\\server\shareName\folder\file.ext".The "localpath" should not be a UNC path as I doubt the first "folder" in your path is a valid Share. Workstations don't normally have Shares setup, except for the default...
14 Apr 2016 by Darshan j
Add following lines of code in your web.config. if you are running on IIS 7 or later add following lines.
9 May 2019 by Member 13353000
How to upload images on MVC Web App razor pages using ASP.NET Core 2.2
12 Mar 2011 by Sergey Alexandrovich Kryukov
You cannot just "upload" something anywhere. You host should be running some service which would respond to your client's request to upload or download something. It can serve such operations using HTML or FTP protocol. You can also build any kind of custom service to support file transfer,...
19 May 2011 by User 1138000
In the last sentence, the "using":using (Stream output = File.OpenWrite(@"C:\myreport.html")) // or whatever path. provider.Export(document, output); // Remember "using System.IO;"By the way, just remove any code related to the file save dialog.
30 May 2011 by FJD.DEETLEFS
using System;using System.IO;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form ...
18 Sep 2011 by Prasanth S
See the linkhttp://forums.asp.net/t/1713181.aspx/1?Adding+watermark+to+an+image+stored+on+the+server+side+folder[^]
18 Sep 2011 by Morgs Morgan
Look here:Resizing a Photographic image with GDI+ for .NET[^]Or a much simpler approach:http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing[^]
18 Sep 2011 by Sudhir Kumar Srivastava lko
This link would help you http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing[^]
19 Sep 2011 by member60
try the following :string directory = AppDomain.CurrentDomain.BaseDirectory + "PhotoGallery/Slides/"; Bitmap originalBMP = new Bitmap(fuphotos.FileContent); int origWidth = originalBMP.Width; int origHeight = originalBMP.Height; ...
19 Sep 2011 by #realJSOP
Why, with extension methods, of course:public static class ExtendBitmap{ public static Bitmap Resize(this Bitmap bmp, int nWidth, int nHeight ) { Bitmap result = new Bitmap(nWidth, nHeight); using(Graphics g = Graphics.FromImage((Image)result)) { ...
15 Jun 2012 by Farhan Ghumra
A DXF Reader Solution and a Simple DXF Viewer[^]CadLib 4.0 DWG DXF .NET Library [^]
27 Jul 2012 by Christian Graus
I ran it in IE from the sample page, and then Chrome. They both acted the same. You're not using AJAX, you're using the Microsoft ASP.NET AJAX controls, which is a different thing. In any case, no library can change how the browser deals with the file upload control, which has all sorts of...
12 Dec 2012 by Krunal Berawala
Hi Everyone,I have requirement where user can upload files from a Page (file size could be 50 MB or more). With normal upload or ajax upload its going to take time when file size is bigger.Is there any way, that once a file is selected, the uploading goes in background and user can...
12 Dec 2012 by Suvabrata Roy
Hi,Solution for Problem 1. Solution for Problem 2 & 3.ASP.NET...
20 Jan 2013 by OriginalGriff
No.There is no such thing as a "parser for any file format", and though it would be possible to create a class that could be expanded to parse new formats, there are so many different formats (just the number of different file formats Microsoft have used over the years is staggering) that it...
4 Apr 2013 by DJAppleboy
I need to upload files to a remote directory but having difficulty in doing so.Any idea or links please?I have tried the web client and also the posted file upload approach.What I need e.g. is www.google.com\file\upload.txt but i get C:\www.google.com\file\upload.txtTry 1...
29 Apr 2013 by Sergey Alexandrovich Kryukov
It absolutely does not matter what kind of "file type" do you upload.The simplest way to upload?
4 Aug 2013 by Dholakiya Ankit
try to see this links @jerrel77 CLick here regards .. :)
4 Oct 2013 by Thomas ktg
Refer this link for limiting the file size using AjaxFileUpload Control.http://stackoverflow.com/questions/17865119/how-to-check-file-size-of-each-file-before-uploading-multiple-files-in-ajaxtoolk[^]
18 Oct 2013 by ASP.NET Community
How to add images in Image Rotator with the help of FileUpload control
22 Nov 2013 by sazzad37
I am using a simple fileupload control to upload my files. Here is my Uploading code, which is fired after clicking a button. if (FileUpload1.HasFile){ FileUpload1.PostedFile.SaveAs(Server.MapPath("~/dataNotices/") + FileUpload1.FileName);} It work's good into localhost but...
17 Dec 2013 by raneshtiwari
You have to use uploadify JS to save file on single click for more details go through below link:http://stackoverflow.com/questions/1979364/jquery-uploadify-file-upload-plugin[^]
18 Dec 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
SolutionAlways follow the second method. You have missed something. let me correct.var validFilesTypes = ["bmp", "gif", "png", "jpg", "jpeg", "doc", "docx", "xls", "xlsx", "htm", "html", "rar", "zip", "txt", "pdf"];function CheckExtension(file) { /*global document: false */ ...
16 Feb 2014 by JoCodes
Try how-to-validate-uploaded-file-in-asp-net-mvc[^]Validate Image Size(Dimension)[^]
1 Dec 2014 by Maciej Los
Have a look at past answers of Sergey Alexandrovich Kryukov[^]. He explain very well, how to resolve this kind of errors.
17 Dec 2014 by Аslam Iqbal
If you use Updatepanel then copy this code under updatepanel:
13 Jan 2015 by shaw2thefloor
Have you had a look at blueimp's jQuery file upload plugin....I think it will do exactly what you want. https://github.com/blueimp/jQuery-File-Upload/wiki/Client-side-Image-Resizing
25 Jun 2015 by j snooze
Indeed the each gentlemen's comments are correct. Process.start from the system diagnostics libary is the console or client way to open a file or start a process(exe, bat file), that doesn't work on a web server because people browsing to your site aren't on the web server. It may work on...
8 Jul 2015 by Sergey Alexandrovich Kryukov
The whole idea behind ASP.NET, as well as all other server-side Web technology, is that you generate content in HTTP response dynamically, by processing HTTP request on the server side and doing required computations before sending the response. Essentially, this is all ASP.NET does.This...
25 Sep 2017 by girishmeena
All the information regarding Ajax file upload control and validation
21 Jan 2011 by Ankur\m/
Apart from what Dylan already said,You can use third party controls for this purpose. Some of them are:Ajax UploaderSWFUploadRAD UploadHope that helps!
10 Mar 2011 by kadiwala naeem
Hello friends....I am uploading files via open dialogue box one by one but I need to upload all the files at a time that means I select all the file from open dialogue box at once and just click on the upload button or link and all the file have to be uploaded into the database.Please...
12 Mar 2011 by motis25
Hello,I am not experienced on C++ programming. Now I am trying to make program which would upload files from my PC to my host. Cannot find any examples on internet.Thank you for your help.
6 Apr 2011 by TanzeelurRehman
Hi I am facing problem with fileUpload control. it is giving error with the following messageAccess to the path 'D:\ProjectWork\CMS\Code\--coa--' is denied.I am using Windows7 platform and visulStudio2010 Ultimate editionRegardsTanzeelurRehman
6 Apr 2011 by M.S.Karthikeyan
you should give read write permission for uploaded file containing folder.
12 Apr 2011 by Dylan Morley
Have a read through this article which describes some best practices and problems you may run intohttp://support.microsoft.com/kb/207671[^]Do not use drive letters mapped to network shares. Not only are there only 26 potential driver letters to select from, but if you try to use a drive...
18 Apr 2011 by mini119
Hello,We are facing an issue with the File upload on our site. We are accepting 4 pdf files from the user one by one. We have set the upload limit to a little less than 2GB in web.config for the staging site. However, even if we upload files totalling up to 1MB, Internet Explorer is giving...
18 Apr 2011 by Prerak Patel
executiontimeo...
18 Apr 2011 by Ankur\m/
You need to check out the logs to determine why the upload is failing. There could be various reasons.Do you have exception handling in place? Check out the application logs.Do you have access to the server your website is deployed to? If yes, the very first place to check is the Event...
20 Apr 2011 by Jeffrey Enzo
You could try Scratchpad: http://picupapp.com/scratchpad.html[^]
19 May 2011 by Member 7838027
hi! i have the code for saving a gridview as an html file using a savefiledialog. i want to save it to a specific path (without using the savefiledialog)... how can i do that? here's my code:SaveFileDialog dialog = new SaveFileDialog();dialog.DefaultExt = "*.html";dialog.Filter =...
29 May 2011 by Dzmoumou
Dear code project members,I'm a very beginer in Visual C# and I would like you to help me with this problem, which is too simple for a high level community like you but very difficult for me.The problem:I have a text file which contains 14 columns and more than 3500 rows of integers. I...
7 Jun 2011 by Jpuckett
Serialize your dataset into JSON, take the JSOn string to a byte array, and append that byte string to the front of your file byte array using additional delimiters so you can strip it out on the WCF side.Result? Single IOStream passed with additional info inside the file itself.WCF...
29 Jun 2011 by wimvr
Hello,I want to have a little code in VB.net to upload a file AND some information (like the name and a login-code of these person). So it will have to perform like these html-form.name: code: file:...
29 Jun 2011 by Shahriar Iqbal Chowdhury/Galib
hi,file uploader do not returns path removing path slashes, they way you are retrieving path might me wrong.You should know where your application is saving files, if so getting full path name is easy,String filename=fileup1.PostedFile.FileName;this actually returns the client filename....
29 Jun 2011 by Anuj Agnihotri
when we upload a file by file uploader nd when i click upload button after that back slash remove in address of file nd we get C:inetpubwwwrootlmsuploaddegert.jpg this address. so how can prevent this plz help thanks in advance..
29 Jun 2011 by Christian Graus
How is this happening ? I've never seen an uploaded path to be missing slashes, you must be doing something to it.
29 Jun 2011 by Al Moje
Hi,I thing you should first copy the file you upload into serverupload location.Let say that in your application root assembly you have a sub directory\UploadFiles.Example code:protected void Button1_Click(object sender, EventArgs e) { if...
13 Jul 2011 by Sicelile
The code worked on wampsever (PHP5) on my laptop. But On this PC, which also uses wampsever PHP 5.3.5 I get an error.here is the html code:Filename:
12 Aug 2011 by vicky87
Hii am trying to upload file on my php server by writing program in C# consoleit read the file for every 5 minutes and upload the file on the serverbut my code is giving me error "unable to connect to server"please help me to set the paths right for local file and online server...
28 Aug 2011 by Or (David) Berkovitch
How to add an 'index' to the file records apearing in fileupload jQuery plugin
26 Aug 2011 by Tejas Vaishnav
Hello all...I have problem while uploading a file to server using file upload control and webservice.i have registration form contains user image and also .doc or .pdf file, now i have to upload that file to the server side directory using a webservice.
26 Aug 2011 by Shahan Ayyub
Check this thread:upload image to web service using c#[^]
26 Aug 2011 by Abhinav S
IF you are using .Net 2.0, you will need to use Web Service Extensions[^] and MTOM.
30 Aug 2011 by Tejas Vaishnav
Hello Friend...I have a Page for Adding a Product to Online Store.that will insert data to database and data like1) Product Name2) Product Code3) Product Description4) Product Price5) Product ImageThe insert method will work like insert the data into database and also...
18 Sep 2011 by Suman Zalodiya
Hi All,I want to save selected file in other folder in windows application.Here what i want to do.I have taken one OpenFileDialog. When i select any file using that dialog, the whole file path shows in textbox as per below codeDialogResult result= openFileDialog1.ShowDialog(); ...
18 Sep 2011 by Suman Zalodiya
I once again one question about image upload.I want to resize the image before saving at other loadtion.For example i have selected "D:\MemberImage\MyPhoto.jpg" with size 500px*350px.Now before saving this file at other location i want to resize this selected file to 160px*120px and...
18 Sep 2011 by Prerak Patel
Resizing a Photographic image with GDI+ for .NET[^]
22 Sep 2011 by jim lahey
Use the FileUpload Control:http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx[^]Details on how to save the uploaded file in this tutorial:http://asp.net-tutorials.com/controls/file-upload-control/[^]
22 Sep 2011 by uspatel
Use FileUpload control and create a folder in your appliction as in example Uploads1 and use this method protected void btnSub_Click(object sender, EventArgs e) { try { string filename = FileUpload1.FileName; ...
27 Sep 2011 by devildx2050
yup i will also try that but FileUpload.HasFile always return false;when i placed FileUpoad control inside a update panel...
24 Oct 2011 by Emged
Hello ! I have a question about uploading a file by XML . I have this part of code , on the server side (Bugzilla) that i can't touch . I just can use the URL in my client side code. public static void UploadPhoto(Photo chosenPhoto) { string uriParameters =...
28 Oct 2011 by CyprusJohn
I am experiencing problems with the FileUpload control inside the EditItemTemplate in a ListView inside an UpdatePanel. FileUpload.FileName is always NULL.I am aware File Upload is not cpmpatible with Update Panels but this can be rectified with use of a PostBackTrigger. However even with a...
30 Oct 2011 by CyprusJohn
Have noticed that if I remove the outer Update Panel, the code works, that is the File Upload control has a file that can be saved to the server. No problems with File Upload control and the Update Panel it is in.The reason for the outer Update Panel was to maintain the scroll position when...
1 Nov 2011 by CyprusJohn
I have been testing my code in Google Chrome, however as a last straw tried it in IE8 and it works perfectly (just had to tweak the outer Update Panel to have UpdateMode="Conditional".The issue is not now a problem with the above code but a browser compatibility issue.Any suggestions how...
14 Feb 2012 by Member 8089914
Please tell me how to upload a XML file using FTP in c#? Im currently using FtpWebRequest method and its giving me The remote server returned an error: (553) File name not allowed. in Stream reqStream = request.GetRequestStream(); linemy code is//Create FTP requestFtpWebRequest request...
13 Mar 2012 by jjjjjjjjjjjssssssssssssaaaaaaaaaa
hi i have taken a file upload control,and a separate button named as upload,and an image control.once i select any image using file upload and when i click that upload button. Then the selected image has to be loaded in image control.please help me how to complete this task.thank you
13 Mar 2012 by Tejas Vaishnav
for your solution you need to do something like this...1) first of all you need to upload you image to any temp or you image folder at server side.2) then make imageurl with newly uploaded image and use server.mappath() to bind imageurl property of your image control.
21 Mar 2012 by Mohankumar.Engain
Dear sir,I have finished my project but finally display error when I registered my details with my image upload using file upload control..."Cannot use a leading .. to exit above the top directory"How to solve this error:while inserting and updating time this error occurred...
21 Mar 2012 by Lakxman
This issue could be due to the page is referring a content that is required in a folder path one level up from the current page path. i.e there could be some mess with the ./../content . There is a discussion about this issue and the suggested solution in the link...
23 May 2012 by kiran34901
From :http://knowledgebaseworld.blogspot.in/2009/02/file-upload-not-working-with-update.htmlIn problem definition we come to know that form must be encoded with multipart/form-data if we want to upload the file; solution is very simple, we just need to change encoded attribute of form...
10 Jun 2012 by Ashish Naval
Hi All,Greetings for the day.I have an issue related to image upload.Actually, currently I have image functionality for .png, .jpg, .jpeg, .bmp, .gif, .psd formats in my asp.net application. For this, I upload these file formats in the image folder and display it where ever required on...
15 Jun 2012 by Pankaj Nikam
Most of the browsers would not be able to handle the images. You need to convert those images on the fly to common formats like JPEG, GIF, PNG... You can use a custom handler to convert the images and produce the compatible formats.
25 Jun 2012 by alibaig
Hi All,I am trying to use Ajax progress bar with Ajax update panel and asp.net FileUpload Control.FileUpload is working with updatepanel using PostBackTrigger in Triggers template.But i want to use them all (Fileupload,updatepanel,progressbar)please share your valuable...
25 Jun 2012 by Sandeep Mewara
FileUpload is working with updatepanel using PostBackTrigger in Triggers template.When it's complete postback (using PostbackTrigger), UpdateProgress does not work directly. You need to work around it using Javascript. Have a look here:Update Progress show on Ajax Full Postback...
27 Jul 2012 by mahesh deore
Hi,I am using ajax AsyncFileUpload control but it does not work in Google Chrome.Please give me the solution for it. It should be return full file path.Mahesh [MRaj]
1 Aug 2012 by Prafulla Sahu
hi What is the difference between FileUpload1.SaveAs()and HttpPostedFile.SaveAs().I know that both are using for uploading file or files to the web server but I want to know more.Please help me
1 Aug 2012 by vjdeeds
Hello Prafulla,To know the difference between FileUpload1.SaveAs()and HttpPostedFile.SaveAs(),you should know the difference between Quote:FileUpload Class and Quote:HttpPostedFile Class. Not to forget that one is a Control and other isn't. Infact FileUpload.SaveAs() uses the underlying...
1 Aug 2012 by vjdeeds
Please check the following linkshttp://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.fileupload.aspx[^]http://msdn.microsoft.com/en-us/library/system.web.httppostedfile.aspx[^]
12 Aug 2012 by ravijain03
When upload document upto 100 mb locally its uploaded successfully.Same configuration settings done in web.config file of hosting site.When i have upload same document using hosting site its give me error "system cannot find the file specified"
12 Aug 2012 by Santhosh Kumar Jayaraman
WHere it is throwing error? I guess the path of the file specified is incorrect or you didnt have your file there in that path. Check the path once again. ANd this error is not related with file size or config. Please have a log file and write the path in it when hosting it in server and...
23 Aug 2012 by Emre Öğreten
ORA-01465: geçersiz onaltılı sayı( wrong hexadecimal number)
23 Aug 2012 by Wendelius
While you update the error or other information describing the problem, the first thing is that you should never concatenate values directly to your SQL statement. This leaves you open to SQL injections, data type mismatches, conversion problems and so on.Always use proper parameter class to...