473,320 Members | 2,020 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,320 software developers and data experts.

Upload

Hi there!

I'd like o k'now how to make un upload of a certain file
to disk in ASP.

Thank you for your time

Nov 17 '05 #1
2 1912
Hi,

In ASP.NET you can upload a file using the File control. Add a File control
from the HTML controls toolbox if using VS.NET or manually with the code:

<INPUT id="File1" type="file" name="File1" runat="server">

Now in CodeBehind you can use the File1.PostedFile on for example
a btnUpload click event like this:

private void btnUpload_Click(object sender, System.EventArgs e)
{
if(File1.PostedFile != null)
File1.PostedFile.SaveAs(@"c:\uploadfolder\data.txt ");
}

Note that you must have write privileges to the folder you upload to set
properly for the user that runs the ASP.NET app.

Good luck!
/Emil

"Alex" <bo*****@kaid4.com.pt> wrote in message
news:0a****************************@phx.gbl...
Hi there!

I'd like o k'now how to make un upload of a certain file
to disk in ASP.

Thank you for your time

Nov 17 '05 #2
You can also use a plain vanilla 'input type="file"' in your page, and in
the PostBack, you can get uploaded files from the Request.Files collection.
Make sure in either case that you set the encoding type of the form to
"multipart/form-data".

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big things are made up of
lots of little things.

"Emil Kvarnhammar" <em**@eqinox.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Hi,

In ASP.NET you can upload a file using the File control. Add a File control from the HTML controls toolbox if using VS.NET or manually with the code:

<INPUT id="File1" type="file" name="File1" runat="server">

Now in CodeBehind you can use the File1.PostedFile on for example
a btnUpload click event like this:

private void btnUpload_Click(object sender, System.EventArgs e)
{
if(File1.PostedFile != null)
File1.PostedFile.SaveAs(@"c:\uploadfolder\data.txt ");
}

Note that you must have write privileges to the folder you upload to set
properly for the user that runs the ASP.NET app.

Good luck!
/Emil

"Alex" <bo*****@kaid4.com.pt> wrote in message
news:0a****************************@phx.gbl...
Hi there!

I'd like o k'now how to make un upload of a certain file
to disk in ASP.

Thank you for your time


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
2
by: Sean Dotson | last post by:
I have a form that passes variables to an asp file and then uploads a file. For some reason the request.form is not getting the info from the form. It's returning blanks. Any insight would be...
0
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancı kaynakli bir scriptti duzenledim yanlız birseyin içinden bir turlu cıkamadım işin aslı ilk defa persistin upload componentini kullanacam yanlız suanki haliyle...
1
by: Alex | last post by:
I am having issues with a script to upload files from a client to a webserver. The problem is not with the actual upload but with where it uploads. The whole process is supposed to create a...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
9
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
2
by: hotflash | last post by:
Hi All, I found the best pure ASP code to upload a file to either server and/or MS Access Database. It works fine for me however, there is one thing that I don't like and have tried to fix but...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.