tags:

views:

335

answers:

2

I asked same question previous day.but becouse of my limited english I cant explain it well

So I decided to explain Step By Step

First

I have php file that gets data and file from HTML form and uploads file to specific directory by $_POST and $_FILES methods..

Second

I have windos aplication (c#).User could drag and drop any file to listview.I send datas of user to php file By POST method and it (php file) upadtes the database.My problem is I wont to send file in listview drag and dropeed by user to php file as It could get file by $_FILES method and acces it.Sory about my english

A: 

Learn HTTP protocol and pray for the site owner won't ban user's IP address for the terms of use violation

Col. Shrapnel
My problem is I dont know how to send file by POST method from c# side
gadirzade
A: 

If you want to POST a single file from C# to your PHP script you could use the UploadFile method:

using (var client = new WebClient())
{
    client.UploadFile("http://example.com/script.php", "POST", @"C:\path\test.txt");
}

If along with the file you want to send some other data and/or multiple files you will need to forge a multipart/form-data request manually. Here's a post explaining how to achieve this.

Darin Dimitrov
Mr Dimitrov I do what you said As Belowusing (var client = new WebClient()){ client.UploadFile("http://K45/j/_dokuman/Dokuman/Islem22.php", "POST", @"C:\test.txt");}
gadirzade
MY "Islem22.php" is like this.But it didnt upload the file to specified directory$filename = $_FILES['DosyaAdi']['name']; $temp = explode('.',$filename);$temp = array_reverse($temp);$Uzanti = $temp[0]; if(move_uploaded_file($_FILES['DosyaAdi']['tmp_name'], "C://www/wamp/j")) { alert( basename( $_FILES['DosyaAdi']['name'])." dosyası başarıyla yüklendi"); }
gadirzade
`UploadFile` uses `file` as name. Try with `$_FILES['file']['name']`. If you want more control over this you may take a look at this article http://www.codeproject.com/KB/cs/uploadfileex.aspx?display=Print
Darin Dimitrov
Thanx Dimitrov.I use $_FILES['file']['name'] file instead of DosyaAdi then everything become Right .Thanks alot
gadirzade