79438213

Date: 2025-02-14 02:41:39
Score: 2.5
Natty:
Report link

Thanks to everyone that helped guide me through this especially @ADyson. Using their link I was able to get the following code to transfer my PNG file properly:

#Initiate cURL object
$ch = curl_init();
#Set your URL
curl_setopt($ch, CURLOPT_URL, 'https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_..../myContainer/myFile.png');
#Indicate, that you plan to upload a file
curl_setopt($ch, CURLOPT_UPLOAD, true);
#Indicate your protocol
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
#Set flags for transfer
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

$headers = array();
$headers[] = 'Content-Type: image/png';
$headers[] = 'X-Auth-Token: '.$myID;
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

#Set HTTP method to PUT
curl_setopt($ch, CURLOPT_PUT, 1);
#Indicate the file you want to upload
curl_setopt($ch, CURLOPT_INFILE, fopen('myFolder/myFile.png', 'rb'));
#Indicate the size of the file (it does not look like this is mandatory, though)
curl_setopt($ch, CURLOPT_INFILESIZE, filesize('myFolder/myFile.png'));
#Execute
curl_exec($ch);
curl_close($ch);
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Blacklisted phrase (1): guide me
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @ADyson
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Brent Curry