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

problem sending file using webrequest to webpage

1
Hi all,

II am having problem sending zip file(binary file) using webrequest function from wince5.0 device to a webpage. It works fine for any file with size less than or equal to 1.5kb. Any bigger files, it did not return any error that i can see but then the sent files are just not stored on the server? They are just lost.

And i tried so many ways but still hopeless. can you please help me out.
Here are my code:

FROM WINCE DEVICE:

.............
FileStream fs = null;
WebRequest req = null;
Stream reqst = null;

fs = new FileStream(SourceFilePath, FileMode.Open, FileAccess.Read);
int totalLength = (((int)fs.Length) + 1);
byte[] buffer = new byte[totalLength];

fs.Read(buffer, 0, buffer.Length);

req = WebRequest.Create(GlobalHandler.g_strUploadUrl);
req.Method = "POST";

req.ContentType = "multipart/form-data";
WebHeaderCollection WH = new WebHeaderCollection();
WH.Add("FileName", MyFileName);

req.Headers = WH;

req.ContentLength = buffer.Length;

reqst = req.GetRequestStream(); //add data to request stream
Print("Geting Request Stream");
reqst.Write(buffer, 0, buffer.Length);// (buffer, 0, buffer.Length);
......................................


CODE FROM WEBPAGE:

.................................................. ............
StreamWriter tw = null;
Stream st = null;
FileStream output = null;


Page.Request.ContentType = "multipart/form-data";
string strFileNamePrefix = Page.Request.Headers.Get("FileName");

st = Page.Request.InputStream;

output = new FileStream(System.String.Concat(dirPath, strUnit, "\\", strDirectory, "\\", TimeStampInFileNameFormat(), ".zip"), FileMode.CreateNew);

Byte[] buffer = new Byte[4096];
int byteReads = st.Read(buffer, 0, 4096);
while (byteReads > 0)
{
output.Write(buffer, 0, byteReads);
byteReads = st.Read(buffer, 0, 4096);
}

st.Close();
output.Close();
May 17 '07 #1
0 1116

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

Similar topics

4
by: | last post by:
I cant seem to find the commmand that I can use to save an image file from a url to my local harddrive. I am looking to save a jpg from a webpage that I have screen scraped. I have a web...
1
by: JoeB | last post by:
hi, Im trying to send data (raw bytes) to a web server. I cannot figure out how to do it. I need the data to be read by PHP which i have already written. The data must be post data. I also...
1
by: ram | last post by:
i have an webpage which i send to all the users manually but i need to automate the procedure so that they can receive webpage by email everyday, anyideas-- Guys?
1
by: Marvin | last post by:
my asp.net app is posting to another webpage using httpwebRequest & x509Certificates and in return the certificate's name used for the posting is sent back. But instead of getting information about...
18
by: jmd | last post by:
Hello, I posted the following in the C# forum but without one answer. But perhaps now in vb.net someone has some guidelines ! This is my question : I want to write a vb.net program that does...
3
by: Paul Porthouse | last post by:
Hi. I have successfully written an automatic file downloader in VB.NET using webrequest but I can't find any information anywhere on how to read in the filename that the server is sending. ...
1
by: Hexman | last post by:
Code below ---- I'm trying to save some specific web pages to disk as text files. I searched the Internet and found a basic example which I changed to fit my needs. I tested it out first on a...
3
by: archana | last post by:
Hi all, My main question is when i send webrequest to server, do ip address related information is also getting send onto server over network? I want to send request using webrequest class....
0
by: pintu | last post by:
Hi..I posted my message earlier but it was not properly described..so am posting again. I am working in an application in which i hav to send the contents of an xml file(from my local machine)...
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: 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
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
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
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...
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...
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.