Im trying to upload a file using an API from a server. i'm using php 7.2 and all documentation from the api is for old php versions. Problem is I don't know how to send this file using curl. My code right know is something like this:
CURLOPT_URL => “http://mySite/MyFolder/api/library?envelope=1”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => array(‘files’ => $_FILES[“UploadedMedia”], ‘expires’ => $fechaExpiracion),
I've never used curl before and the posts i've seen before use ftp or some other ways to upload files with curl but i have to do it using curl postfields and to the api url as far as i know.
Any advice is welcome.
Thanks in advance, Marco.
question from:
https://stackoverflow.com/questions/65660289/curl-and-post-to-upload-a-file-to-a-server-using-an-api 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…