upload files

  • Thread starter Thread starter sonu
  • Start date Start date
S

sonu

I want to upload files without file control.

suppose i have string "c:\test.txt"

i am using this

FileInfo Myfile= new System.IO.FileInfo("c:\test.txt");

string strBaseLocation = "c:\\amit\\";

objFile=(HttpPostedFile)Myfile; there is an error in this line cant
cast like this

objFile.SaveAs(strBaseLocation+Myfile.FullName);

please help me
 
sonu,

Are you trying to copy the file on the local machine? Or to the c:\amit
directory on a web server (I don't know why you are using the HttpPostedFile
type).

If you want to upload a file to a website, you should use the UploadFile
method on the WebClient class. If you want to copy a file, then you want to
check the static Copy method on the File class.

Hope this helps.
 
I am tring to upload the file on webserver from client.
i want upload files from client to server with out using file control.
please give me link or sample of code about that.
 
sonu,

Check out the documentation for the UploadFiles method on the WebClient
class. It should give you an idea how to do this.
 
Nicholas,

I tried and found this erroe

"The remote server returned an error: (405) Method Not Allowed."

what is the problem.
 
Sonu,

Files can be posted in a number of ways. You can issue a POST or a PUT.
Are you sure that the website that you are uploading to allows files
supports this?
 
Thanks Nicholas, for giving the valuable information

I Had to write the Reciever side code also for uploading the file.
i did that and find result.


Sonu
 
Nicholas i want to System property like java "System.Getproperty()"

Actualy i want to know the loged person name.

Any information?
 
Back
Top