473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

1
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 programmatically 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 5369
Plater
7,872 Expert 4TB
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 64KB
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 Expert 4TB
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 100+
@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
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"...
1
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...
0
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...
0
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...
6
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...
1
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...
2
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
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
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...
0
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...

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.