Click here to Skip to main content
15,890,609 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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:
HTML
<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
Updated 8-Jan-13 3:13am
v2
Comments
Sergey Alexandrovich Kryukov 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

 
Share this answer
 
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.
Sergey Alexandrovich Kryukov 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 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 9-Jan-13 1:20am    
"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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900