473,386 Members | 1,621 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,386 software developers and data experts.

Uploading document in C#

Hi,
I am working on a web based apllication where user will upload the registration form and the form will save on a perticular server.the code which i am using is :

string strname;
strname = System.IO.Path.GetFileNamefileUpload.PostedFile.Fi leName);



fileUpload.PostedFile.SaveAs(Server.MapPath(strnam e));

The problem is this when i upload the document it alwayes goes to my folder where this application is placed.(D:\\UploadApp) i want to change the path,is this possible.I am very much new in web application so if there is problem in concept plz. help me.

Thanks,
Shailesh Kumar
Nov 22 '07 #1
2 1253
Hi,
I am working on a web based apllication where user will upload the registration form and the form will save on a perticular server.the code which i am using is :

string strname;
strname = System.IO.Path.GetFileNamefileUpload.PostedFile.Fi leName);



fileUpload.PostedFile.SaveAs(Server.MapPath(strnam e));

The problem is this when i upload the document it alwayes goes to my folder where this application is placed.(D:\\UploadApp) i want to change the path,is this possible.I am very much new in web application so if there is problem in concept plz. help me.

Thanks,
Shailesh Kumar
hi shailesh,
try the following;
Expand|Select|Wrap|Line Numbers
  1.                      string strFilePath="..c:\\foldername"+strname;
  2. //.. indicates the server
  3. //instead of c:\\foldername use the path as per your requirement
  4.                     fileUpload.PostedFile.SaveAs(strFilePath));
  5.  
  6.  
i hope this will solve the problem.
Nov 22 '07 #2
I apologise that I didn't start a thread but continue from this.

I've used this method to save file into my server and it's working.
Now I need to provide my users to download them with a button.

May I know how to do that? The response.redirect is not working for me.

Expand|Select|Wrap|Line Numbers
  1. protected void btnLink_OnClientClick(object sender, EventArgs e)
  2.     {
  3.         String pid = Convert.ToString(Session["pid"]);
  4.         String[] file = System.IO.Directory.GetFiles((Server.MapPath("Docs/")+ pid +"/"), "myDesiredFileName.*");
  5.  
  6.       //  Response.Write(file[0]);
  7.         Response.Redirect(file[0]);
  8.  
  9.     }
btw, It got file name and directory correctly.
Nov 22 '07 #3

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

Similar topics

4
by: dickiedyce | last post by:
Hi there. I've spent the weekend getting ever more frustrated, trying to get an upload file function working on a website. The site is hosted by a company called oneandone. They're using PHP...
2
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and...
5
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
4
by: Mark Miller | last post by:
I've been trying to execute a javascript function just before submit on a form that contains an <input type="file"> input field and it isn't working. The reason I want to do this is the end users...
1
by: neoret | last post by:
Hi there. I need to perform an upload of a document using HTTP post. This has to be done from my windows form using C#. My challenge is: 1: To send - the word document 2: To attach several...
5
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or...
4
by: | last post by:
Can someone offer or point me to some sample code or advice on how to upload a document from a web page and store it into a SQL Server image field? And then reverse the process and serve up the file...
4
by: Rob Meade | last post by:
Dear all, We have purchased a product called SA-FileUp which we have used in our organisation for a number of years, I'm quite an an avid supporter of it, recently I've been trying to ensure...
3
by: zo62 | last post by:
I am building an XML document thru code then saving it on my local machine as well as posting it the an FTP site. When opening the XML document in my local machine. the Document is well indented and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.