-1

We have PHP code on a server that receives files into $_FILE and then stores them based on user/security considerations.

We have client code that processes some data and generates a file into a variable $fileToSend- as one example, think of the output from a file that the client has read and encrypted, or as another example think of the results from generating file to a variable using FDPF's Output("", "S") which returns the resulting PDF file as a string. The $fileToSend could be pretty large (500MB).

We could save the variable as a file and then send the file as a curlFile using curl, but that just seems wasteful of time, space and effort.

How can we POST from a variable on the PHP client side and have it appear in $_FILE on the server side?

Mark Kasson
  • 1,600
  • 1
  • 15
  • 28
  • 1
    I think this is what you're asking.http://stackoverflow.com/questions/3085990/post-a-file-string-using-curl-in-php If I understand, you want to avoid writing the string data you already have to disk just to read it back out again for a cURL request. – Michael Berkowski Aug 12 '15 at 13:58
  • Exactly. And that prior SO question is the right direction. Was hoping there was a way other than handcrafting the POST fields for curl. I imagine a non-text file needs encoding in base64 and some indicator that it is encoded. Maybe I'll make it a class and post it for public consumption. Michael, if you make yours an answer, I'll pick it (unless someone shows up with a pre-baked easier answer). Really? Downvoted? – Mark Kasson Aug 12 '15 at 22:08

1 Answers1

0

You have to only send file name which are store in variable and then you have to read that file using file handling function at server side we can't directly or virtually send any file to server. but you can serve like this to perform this action.

Hiren Raiyani
  • 754
  • 2
  • 12
  • 28