-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?

2
  • 1
    I think this is what you're asking.stackoverflow.com/questions/3085990/… 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. Commented Aug 12, 2015 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? Commented Aug 12, 2015 at 22:08

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

"we can't directly or virtually send any file to server." I believe that is incorrect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.