473,698 Members | 2,337 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How can i fill “Choose File Upload Dialog” programmaticall y using C#

1 New Member
Im working on a project in which i have to upload a file. I have tried WebHttpRequest class and WebClient class to do this but could not succeed. So, if i programmaticall y fill and click the choose file dialog then it can be done otherwise not. Im using C# for this project.
Aug 4 '12 #1
4 5402
Plater
7,872 Recognized Expert Expert
Are you developing something that runs for a webpage or for windows?
I do not understand what you are asking?
Aug 6 '12 #2
Mudassir
85 New Member
well for uploading files into the database using a file upload lets assume uploading images you can do as follows
Expand|Select|Wrap|Line Numbers
  1. if (fuPhoto.HasFile) // fuPhoto is the name of file upload
  2.                 {
  3.                     string path = Server.MapPath("~/profile/");
  4.                     string file = fuPhoto.PostedFile.FileName;
  5.                     fuPhoto.SaveAs(path + file);
  6.                     string[] ext = file.Split('.');
  7.  
  8.                     if (Request.Cookies["ProfilePic"] == null && Request.Cookies["Extension"] == null)
  9.                     {
  10.                         HttpCookie profileCookie = new HttpCookie("ProfilePic");
  11.                         profileCookie.Value = ext[0].ToString() + "." + ext[1].ToString();
  12.                         profileCookie.Expires = DateTime.Now.AddDays(1);
  13.                         Response.Cookies.Add(profileCookie);
  14.  
  15.                         HttpCookie extensionCookie = new HttpCookie("Extension");
  16.                         extensionCookie.Value = ext[1].ToString();
  17.                         extensionCookie.Expires = DateTime.Now.AddDays(1);
  18.                         Response.Cookies.Add(extensionCookie);
  19.                     }
  20.                     else
  21.                     {
  22.                         Response.Cookies["ProfilePic"].Value = ext[0].ToString() + "." + ext[1].ToString();
  23.                         Response.Cookies["Extension"].Value = ext[1].ToString();
  24.                     }
  25.                     if (!ClientScript.IsStartupScriptRegistered("alert"))
  26.                     {
  27.                         ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('File has been uploaded..'); 
  28.                     }
  29.                 }
  30.  
  31.  
now you can save the file by your query into the database..
...
Addan
Aug 7 '12 #3
Plater
7,872 Recognized Expert Expert
Ok so yes you are dealing with a webpage.
For security reasons, browser do not let you autofill the the values for file uploads.
You could *TRY* making a customized silverlight control(think activeX or a java applet) for the webpage, but seems a bit exccessive.
Aug 13 '12 #4
ariful alam
185 New Member
@Mudassir,

You wrote in first uploading a file in database. but you may be used file system here. isn't it?
Aug 13 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2673
by: Brian Birtle | last post by:
**** A CHALLENGE TO THE GURUS - refute the statement "It's impossible to build a file upload progress meter using ASP.NET" **** First person to prove me wrong gets "All Time .NET Programming GOD" listing in my address book and (optionally) their name listed on my "news" page of my birtle.com website (listed as "Jane Smith is a Programming GOD") for at least a month. Why not take a moment to read more and possibly boost your ego to all time...
1
1305
by: Frank Quinty | last post by:
Hi there, I try to offer a file upload in my web site. The server is Windows Server 2003 SP1, framework .net 1.1. It runs fine if the file is smaller than around 260 kb. If the file is bigger, I always have the error : "Maximum request length exceeded" I read many post about this error , and configuring the AspMaxRequestEntityAllowed to a bigger value (1073741824), but I still have
0
2475
by: Raven Jones | last post by:
Heya all, I'm working on a web-based application (using ASP.NET and C# on .NET 1.1.4322, supporting only IE6 for Windows) that allows for file uploads. Screen real estate is at a premium, so I want to set its style to "display: none;" and interact only with the standard file upload dialog (which can be summoned by firing the click() method of the control). Attempting programmatic access of a file upload control is generally playing...
0
1112
by: Nemisis | last post by:
I am creating a asp.net 2.0 website that can be accessed via a PDA. On the page i have a file upload .net control, which works fine on its own. I can check the HasFile property and upload the file to the server. If i then change the page to use a MasterPage, the file upload control doesnt work!! It will allow me to choose a file, but when i try to upload it, the HasFile property is false instead of true. Has anyone else had this...
6
10099
by: Marko Vuksanovic | last post by:
I am trying to implement a file upload progress indicator (doesn't have to be a progress bar) using atlas... I do realize that the indicator cannot be implemented using Update panel control, but is it possible to implement it using some other control, for example a floating window?
1
1722
by: =?Utf-8?B?UmFq?= | last post by:
I am implementing file upload - progess bar using IHttpModule When uploading file, the web page starts uploading file after some delay depending upon the size of the file selected. If the file size is small page may do it faster and if the file size is big the process will take some time, I am not refering the actual movement of the file but the process it takes to start itself. How can I identify when excatly this process starts? ...
2
2471
by: tabu5in | last post by:
I have faced a big problem, when i was upload 800mb file using PHP. it does not works propperly. Please help me. if possible then please send me the source code.
6
2904
by: shalinikonatam | last post by:
Hello Every One I need multi file upload progress bar with out using perl. If any one knows plz help me. Thanks in advance.
0
1131
Manikgisl
by: Manikgisl | last post by:
HI!!, File Upload and Download using FTP C#.net We are very tired of Found out to Upload and Download
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.