Hello (sorry for my bad English), so basically i'm creating a simple c# application that retrieves .txt
files located within the documents directory. My program is going to allow users to open these text files and edit them, then upload to my website.
the text files i'm looking to retrieve are located in this path:
Libraries -> Documents -> XYZtxtMapper -> Savedstuff -> example.txt
I'm looking for some sort of way in c# to receive the example.txt file within the path shown above, once I've retrieved the example.txt file i would call a API on my server, example:
var client = new WebClient())
client.DownloadString("https://example.com/file=" + example.txt); //<- Calls my API
Once the above is called i would use PHP to $_GET['file']
, then what PHP code would i use to upload the txt file that i use $_GET['file']
to my server? Could i use fwrite()
to upload the file to my server (website)?
Sorry for my bad English and me being a noob! I'm still pretty new to all this programming stuff
Your English make your explain not very well. As I understand, you want use a C# app to send a string to your server via GET
method, then get it's response, right?
Then if you use WebClient:
WebClient wc = new WebClient();
string yourString = File.ReadAllText("C:\\path\\toYourFile.txt"); // Read file content
// string yourString = "C:\\path\\toYourFile.txt"; // Or you want send filename
string response = wc.DownloadString("https://example.com/pathTo/yourPHPFile.php?file=" + WebUtility.UrlEncode(yourString));
Note: You have to include pathto/yourPHPFile.php?file=
to your URL, where pathto/yourPHPFile.php
is your php file, ?
is the begin your query. If you unfamily with this, read more about PHP GET
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.