PHP and Curl to send an image to a Photon

I have a webhook which calls my webserver correctly, and I get data I want just fine. However, the purpose of the hook is to ask the local server if there is an update pending, as WiFi on the photon is off for all but 30 seconds of a day to save on battery. Basically, whenever it wakes up, it asks if there is an update, and the webhook should get my server to send the device the file using the REST upload API (which I can do from the command line just fine). Problem is, I can’t seem to get the cURL options in PHP right to actually send the data. So, my question is, can anyone tell me how PHP cURL can be used to send the file. It’s the -F options that are killing me. I’ve thought about a URL string, but I would rather do this so I can more easily port it to other solutions.

Thanks for any help anyone can give me.

Hi @peteb

Here is the example from docs using curl:

curl -X PUT -F file=@my-firmware-app.bin -F file_type=binary

Have you tried something similar to this?

I can use cURL from the command line. I need to know how to use PHP to do the same thing. The PHP cURL set opts don’t neatly translate and I have not used cURLFile before. I don’t seem to be getting it right. Just using a URL doesn’t work either.

When I have PHP questions I always ask my friend @wgbartley! Maybe he can help here.

There is also a good stack overflow page here:

I’ll try that cURLFile implementation later today. I skipped a lot of stack exchange search results, but that may be the one I was looking for. It seems to solve the problem from a high level point of view.

Thank you