Click here to Skip to main content
11,639,861 members (59,138 online)
Rate this: bad
good
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
Edited 8-Jan-13 3:13am
v2
Comments
Sergey Alexandrovich Kryukov at 8-Jan-13 21:41pm
   
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 at 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.
Sergey Alexandrovich Kryukov at 9-Jan-13 1:19am
   
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 at 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
Sergey Alexandrovich Kryukov at 9-Jan-13 1:20am
   
"Doesn't work" is not informative...
—SA
Dariodsa at 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
0 Suvendu Shekhar Giri 330
1 CPallini 177
2 F-ES Sitecore 170
3 sasanka sekhar panda 155
4 jyo.net 142
0 OriginalGriff 9,081
1 Sergey Alexandrovich Kryukov 8,847
2 Mika Wendelius 7,027
3 Suvendu Shekhar Giri 2,650
4 F-ES Sitecore 2,558


Advertise | Privacy | Mobile
Web01 | 2.8.150731.1 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2015
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