0

I want to have a page where the user makes a request using a known format through CURLing a URL, and the file they provide is then uploaded to the server.

The URL would be like this: http://localhost/fileupload.php?FilePath=c:\testfile.txt

However, all the guides online work off of form submission or JQuery AJAX requests - can this be achieved with pure PHP?

aminography
  • 21,986
  • 13
  • 70
  • 74
seanbulley
  • 15
  • 1
  • 5
  • It's not really clear what your use case is. By "pure PHP" do you mean that your user is writing or executing PHP code on the client machine? Are you just asking how to make an HTTP POST request in cURL that includes a file? – David Nov 23 '19 at 20:23
  • Check below i reedited my code with explanation – Nalin Nishant Nov 23 '19 at 20:26
  • The user is on their Linux machine, and using "curl http://myserver.com/fileupload.php?FilePath=/home/user/file.txt" for example – seanbulley Nov 23 '19 at 20:28
  • So you just want to upload a file with `curl`? A quick Google search for "upload a file with curl" finds this: https://stackoverflow.com/questions/12667797/using-curl-to-upload-post-data-with-files – David Nov 23 '19 at 20:31
  • 1
    I don't think this would be possible, since the server can't access any files on the client machine, by just providing the filename. The client would need to be the one providing the contents of the `c:\testfile.txt` – Chris Nov 23 '19 at 20:36

0 Answers0