Click here to Skip to main content
12,448,059 members (91,261 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# webresponse
I want to send a audio file saved in isolated storage put on web server. I will try to do that with send data using web request.

link 127.0.0.1/info2013

Html code:
<form name="upload" method="post" action="upload.php" enctype="multipart/form-data">
      <input type="file" name="Image"><br> 
	  <input type="submit" value="Upload">
	</form>
Php code
 copy ($_FILES['Image']['tmp_name'], $_FILES['Image']['name']) or die ('Could not upload');
?>
Ok I think that will work. But I didn't know how to make a web request in c#, windows phone 7 sdk. So can you help me. Thanks a lot.
Posted 8-Jan-13 2:50am
Updated 8-Jan-13 3:13am
v2
Comments
   
I'm answering, but it is not really a question. Maybe, that's you did not have any response for so long time...
—SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Dariodsa 9-Jan-13 1:08am
   
There is no code sample how to send file from isolated storage to the web server. Thanks very much if you can find it.
   
First of all, how come it's in isolated storage? Why?
Second of all, ever heard of separation of concerns? Isolated storage is one thing, HTTP request is another. They are absolutely not related; there is no a sample doing both thing (strange idea), and you won't need such sample.
A file is a file. What's the problem? How to use isolated storage? Well, see System.IO.IsolatedStorage.IsolatedStorage, System.IO.IsolatedStorage.IsolatedStorageFile. After all, how did you put your file in isolated storage? If you know that, you should know hot to read it.
That's it.
—SA
Dariodsa 9-Jan-13 1:14am
   
private void UploadFile()
{
/*using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
using (var _data = new IsolatedStorageFileStream("zvuci/zvuk.wav", FileMode.OpenOrCreate, store))
{

}
}*/
IsolatedStorageFile isf = Utilities.IsoStore;
FileStream _data = isf.OpenFile("zvuci/zvuk.wav",FileMode.Open);
string uploadUri="http://127.0.0.1/info2013/";

byte[] fileContent = new byte[_data.Length]; // Read the contents of the stream into a byte array
MessageBox.Show(fileContent.Length.ToString());
int bytesRead = _data.Read(fileContent, 0, fileContent.Length);

WebClient wc = new WebClient();
wc.OpenWriteCompleted += new OpenWriteCompletedEventHandler(wc_OpenWriteCompleted);
Uri u = new Uri(uploadUri);
wc.OpenWriteAsync(u, null, new object[] { fileContent, bytesRead }); // Upload the file to the server
}

private void PushData(Stream input, Stream output)
{
byte[] buffer = new byte[4096];
int bytesRead;

while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
{
output.Write(buffer, 0, bytesRead);
}
}
doesn't work
   
"Doesn't work" is not informative...
—SA
Dariodsa 9-Jan-13 1:23am
   
Ok.
Can you give me an example how to post file on local server?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160811.3 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100