views:

1713

answers:

4

Hi

I'm working on trying to ftp a file to the server through a silverlight application. Where the location to upload the file on server file system, exists outside the sandbox area for the web server. In this case the web server root exists at "C:\test\www\" and the location to upload the file will exist at "C:\User\Uploads". In this scenerio i'm not sure if Http POST will work (doesn't that use the web server root). I just need to upload the file selected by the user to a different location that may exist outside the sandbox. With silverlight i'm thinking sockets are my last option based on the limited port range for silverlight being 4502-4532. Can i do this using WebClient and Http POST? Can i make an ftp connection through silverlight or javascript?

A: 

Assuming your server is ASP.NET based I would use a simple WebClient POST into a .ashx handler. Have the handler write the body of the post to a file in "C:\User\Uploads".

AnthonyWJones
The server is apache 2.2. And your suggestion will work with asp.net but wondering if there might be another way with out using asp.net
Curtis
+2  A: 

This is an interesting scenario, since it sounds like you are doing this all on the same machine (both client and server). I am responding to the vague original question, and would love additional data to help answer this completely.

FTP uploading itself is not supported by Silverlight, but the concept of uploading a file is, through an HTTP stream of data.

If you want to do an HTTP upload from a client machine to the server: You can use the OpenFileDialog control in Silverlight 2 and 3 to read that data, then use WebClient to upload it.

If you want to do a download from something your web server can send, to the client machine, then you'd need to use Silverlight 3 or newer, which features a SaveFileDialog control.

All Silverlight file dialogs require a user-initiated action for them to work, function, and the user will need to select the file name(s) for security purposes.

Hope this helps!

Jeff Wilcox
A: 

I have a similar problem. I want to read (not nnecessary donload) a file that is in the server machine usiong silverlight any tip?

Matheus Lebrão
A: 

As long as the ftp server is on the same host as the silverlight app you can use sockets and code your own ftp client, its not very hard and there's plenty of examples out there.

bar10dr
Silverlight does contain socket support. When using Silverlight 3 the sockets had a limited port range of 4502-4534. This range was too limiting for the overall design I was implementing.
Curtis