473,288 Members | 1,718 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,288 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 1250
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.