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

Take input type=file without server

Hello,

this is been frustrating me all morning. Any help would greatly be appreciated

I have a site (not my own, not done in asp.net) that will be posting data to
my c# page. There is an input type=file in that form. How do I get the value?

All the examples I see online tell you to set your form up as runat=server
but tha won't work in this case since I won't be dealing directly with the
form, just the returned data. This is what I have, it fails because it cant
convert a string to an HtmlInputFile... thoughts?

HtmlInputFile filMyFile = (HtmlInputFile)Request.QueryString["uplTheFile"];
// Convert to HttpPostedFile?

HttpPostedFile myFile = filMyFile.PostedFile;
int nFileLen = myFile.ContentLength;
byte[] myData = new byte[nFileLen];
string fileName = myFile.FileName;
string strBaseLocation = "c:\web\upload";
myFile.InputStream.Read(myData, 0, nFileLen);
FileStream newFile = new FileStream(strBaseLocation+fileName,
FileMode.Create);
newFile.Write(myData , 0, myData.Length);
newFile.Close();
Nov 9 '05 #1
1 1703
Use Request.Files instead...
--
Patrice

"ashton" <as****@discussions.microsoft.com> a écrit dans le message de
news:58**********************************@microsof t.com...
Hello,

this is been frustrating me all morning. Any help would greatly be appreciated
I have a site (not my own, not done in asp.net) that will be posting data to my c# page. There is an input type=file in that form. How do I get the value?
All the examples I see online tell you to set your form up as runat=server
but tha won't work in this case since I won't be dealing directly with the
form, just the returned data. This is what I have, it fails because it cant convert a string to an HtmlInputFile... thoughts?

HtmlInputFile filMyFile = (HtmlInputFile)Request.QueryString["uplTheFile"]; // Convert to HttpPostedFile?

HttpPostedFile myFile = filMyFile.PostedFile;
int nFileLen = myFile.ContentLength;
byte[] myData = new byte[nFileLen];
string fileName = myFile.FileName;
string strBaseLocation = "c:\web\upload";
myFile.InputStream.Read(myData, 0, nFileLen);
FileStream newFile = new FileStream(strBaseLocation+fileName,
FileMode.Create);
newFile.Write(myData , 0, myData.Length);
newFile.Close();

Nov 9 '05 #2

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

Similar topics

5
by: Don | last post by:
Is there some way to populate the "Browse" box for a <input type=file...> with a default value? I can do it for <input type=text...>, but can't seem to do it for <input type=file...>. Any ideas?...
7
by: garbagecatcher | last post by:
Hello, here's my problem: On my web server I generate a file, I need to send this file to a different web server. I have no control over the other web server. The only way they accept...
3
by: Roberto | last post by:
I have the following problem: I have the following form client side: <FORM.......> <FORM action="./WZUpload.asp" method="Post" enctype="multipart/form-data" WIDTH=100%> <INPUT Type="file"...
2
by: Quick Function | last post by:
For the <input type="file">, can I select directory? Multiple directories? Thanks, qq
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
1
by: ashton | last post by:
Hello, this is been frustrating me all morning. Any help would greatly be appreciated I have a site (not my own, not done in asp.net) that will be posting data to my c# page. There is an input...
3
by: ramkum | last post by:
Hi, I'm building a system where a presenter uploads a PPT to my server and then I show it to all the participants. The problem is that most of the media in the PPT is usually linked, so I'll...
2
by: ramkum | last post by:
Hi, I'm building a system where a presenter uploads a PPT to my server and then I show it to all the participants. The problem is that most of the media in the PPT is usually linked, so I'll...
4
by: SammyBar | last post by:
Hi all, I wonder is it possible to upload the content of an <imgfield to a server. The content of the <imgwas downloaded from a web site different from the one it should be uploaded. The image...
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: 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...
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...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.